3

I use the pnet tcp/udp toolbox) along with psychtoolbox to communicate between two instances of matlab in different machines. One of my machines is a 32 bit win7 running matlab 2010b. The other is a 64 bit win 7 running matlab 2012a. I have a problem in transferring data from one computer to the other.

Experiment 1: Run the udp_send_demo from the 64 bit computer while running the udp_plotter_demo from the 32 bit computer. Expected result: 32 bit computer plots data, waits for keyboard input. If Kb input, close figure and end demo. 64 bit finishes sending and stops demo. Actual result: 64 bit behaves as it should. 32 bit computer plots but hangs and refuses to close the demo. It does not respond to any keyboard input and has to be force closed.

Experiment 2: Run above experiment in reverse with 32 bit sending and 64 bit reading. Expected result: 64 bit plots and waits for Keyboard input. If kb input found, stop demo. Actual result the 64 bit matlab crashes claiming a segmentation violation in the mex file. It displays a stack trace (I am appending a part of it at the end).

Playing around with the port numbers makes no difference. Recompiling the 'pnet.c' source file instead of using the precompiled mex makes no difference. Question: Has anybody tried something like this? Did you get it to work? Can you suggest things to try to get this to work without having to install 32 bit matlab in my Win64 computer?

============

Code:

SERVER SIDE:

udp_send_demo('sin(0:0.1:6)',clientIPStr,portToListen)

CLIENT SIDE:

udp_plotter_demo(portToListen)

=============

Stack Trace


Segmentation violation detected at Sat Sep 29 16:41:11 2012

Configuration:

Crash Decoding : Disabled

Default Encoding: windows-1252

MATLAB Root : C:\Program Files\MATLAB\R2012a

MATLAB Version : 7.14.0.739 (R2012a)

Operating System: Microsoft Windows 7

Processor ID : x86 Family 6 Model 58 Stepping 9, GenuineIntel

Virtual Machine : Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode

Window System : Version 6.1 (Build 7601: Service Pack 1)

Fault Count: 1

Abnormal termination: Segmentation violation

Register State (from fault): RAX = 0000000000000000 RBX = 0000000000000000

RCX = 000000005d0df7d7 RDX = 0000000000000001

RSP = 00000000040671b0 RBP = 0000000004067289

RSI = 000000000000003d RDI = 000000000000003d

R8 = 000000005d0df7d6 R9 = 000050490ee40167

R10 = 000000000000003d R11 = 0000000000000000

R12 = 0000000000000008 R13 = 000007fefb997678

R14 = 0000000000000002 R15 = 0000000000000002

RIP = 000007fefb99238a EFL = 00010202

CS = 0033 FS = 0053 GS = 002b

Stack Trace (from fault):

[ 0] 0x000007fefb99238a C:\Users\ephys-data\Desktop\temp\tcp_udp_ip\pnet.mexw64+00009098 ( perror+004298 )

[ 1] 0x000007fefb99389b C:\Users\ephys-data\Desktop\temp\tcp_udp_ip\pnet.mexw64+00014491 ( mexFunction+001979 )

[ 2] 0x0000000074f10f63 C:\Program Files\MATLAB\R2012a\bin\win64\libmex.dll+00069475 ( mexRunMexFile+000131 )

[ 3] 0x0000000074f0fce2 C:\Program Files\MATLAB\R2012a\bin\win64\libmex.dll+00064738 ( inSwapMexfileReader+000226 )

[ 4] 0x0000000074f0fe58 C:\Program Files\MATLAB\R2012a\bin\win64\libmex.dll+00065112 ( inSwapMexfileReader+000600 )

[ 5] 0x0000000074e4b046 C:\Program Files\MATLAB\R2012a\bin\win64\m_dispatcher.dll+00045126 ( Mfh_file::dispatch_fh+000486 )

....more stuff....

This error was detected while a MEX-file was running. If the MEX-file is not an official MathWorks function, please examine its source code for errors. Please consult the External Interfaces Guide for information on debugging MEX-files.

If this problem is reproducible, please submit a Service Request via:....

A technical support engineer might contact you with further information.

Thank you for your help.


Thanks

-b

bas
  • 209
  • 2
  • 10
  • Did you compile the .mexw64 file yourself? I don't see one in the pnet distribution, just .mexw32. – Andrew Janke Sep 30 '12 at 00:47
  • the latest psychtoolbox comes with a precompiled .mexw64. however, i did try to recompile it myself. it did not make any difference – bas Sep 30 '12 at 01:33
  • Have you also tried running this between two 32-bit or two x64 computers, to make sure the bitness difference is the issue, and not that it's always the reader that has the problem? I think your expected behavior for the reader might be off a bit: the `udp_plotter_demo` code loops over calls to pnet('readpacket'), which I think will block indefinitely by default. Since it's blocked in a mex file it may not respond to keyboard input while waiting for another packet. Note the comment says "use timeout to not block forever" but the actual function call doesn't pass a timeout value. – Andrew Janke Sep 30 '12 at 01:54
  • I'm saying - that segfault is certainly bad. But the 64->32 case might be behaving as written. To test it, try running `udp_send_demo` multiple times against it with different inputs and see if you get multiple plots. If you do, it's blocked in `pnet(udp,'readpacket')` as written, and the x64 crash in Experiment 2 is a separate issue. – Andrew Janke Sep 30 '12 at 01:59
  • When does the x64 version crash? When you first run `udp_plotter_demo` or after you've sent it data with `udp_send_demo`? – Andrew Janke Sep 30 '12 at 02:01
  • "But the 64->32 case might be behaving as written" - thanks for that insight. I'll test it out ASAP. I have been working with a 32bit-to-32bit connection without problem for the past few years. I dont have another 64 bit currently to check if that is the issue. However, the x64 crashes only after i send the data out from the x32. in the meanwhile, it plots a figure and sits waiting for data to stream to it from the other computer – bas Sep 30 '12 at 02:11
  • You could run both the sender and receiver on two separate Matlab processes on the same x64 machine. Networking to localhost should work basically the same as between hosts. – Andrew Janke Sep 30 '12 at 02:14
  • x64 - x64 fails in the exact same way. I get the same segfault. And the matlab crashes – bas Oct 02 '12 at 17:38

1 Answers1

1

I wrote the helpful folks at psychtoolbox. Apparently the bug was caught and resolved in the 'beta' version of psychtoolbox. If you have the latest and greatest psychtoolbox, run UpdatePsychtoolbox for a good night's sleep. See here

bas
  • 209
  • 2
  • 10