Back to the main page.

Bug 472 - Matlab crashes after call to ft_write_data

Status CLOSED FIXED
Reported 2011-02-03 22:14:00 +0100
Modified 2011-03-31 14:13:52 +0200
Product: FieldTrip
Component: realtime
Version: unspecified
Hardware: Macintosh
Operating System: Mac OS
Importance: P1 critical
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Philip van den Broek - 2011-02-03 22:14:18 +0100

During debugging, fieldtrip buffers are installed and destroyed several times. At some point, Matlab entirely crashes, it just disappears even without a crash report. The terminal provides the following information: MATLAB(4080,0xb56a8000) malloc: *** mmap(size=504000512) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Out of memory with unchecked malloc in line 106vpn-85-36:~ philip$ Running Matlab 2010a and a recent FieldTrip version (third week of January) The code below replicates the behavior: function testft % start without a buffer ft_destroy_buffer % number of attempts cnt = 1; % use default url url = 'buffer://localhost:1972'; % dummy header hdr.Fs = 256; hdr.nChans = 100; % after a few attempts, Matlab crashes while(1) disp(['counter: ' num2str(cnt)]); cnt = cnt + 1; ft_create_buffer(1972); ft_write_data(url,rand(hdr.nChans,10000), 'header', hdr, 'dataformat', 'fcdc_buffer', 'append', false); ft_read_header(url) ft_destroy_buffer pause(0.1); % probably meaningless end


Robert Oostenveld - 2011-03-01 20:41:20 +0100

I cannot reproduce the error on my MacBook pro (OS X 10.6.6) with MATLAB 2010a and using th ecurrent fieldtrip. I don't think that there are any relevant changes to the buffer mex file (which seems to be causing the crash). Are your computer details different? ------------------------------------ In main: spawning tcpserver thread ans = Fs: 256 nChans: 100 nSamples: 10000 nSamplesPre: 0 nTrials: 1 orig: [1x1 struct] label: {100x1 cell} Entering exitFun() routine requesting cancelation of tcpserver thread cleaning up list entry localhost:1972 counter: 121 ...


Philip van den Broek - 2011-03-01 21:52:52 +0100

You are right, in 64-bit mode, it doesn't crash, although ultimately I think it will because memory usage increases every time a new buffer is created and destroyed. This memory is not released if you stop the loop and execute clear mex. Using 32-bit Matlab2010a, it crashes after a few attempts. I am sorry, I forgot to mention this 32-bit detail.


Robert Oostenveld - 2011-03-02 09:03:23 +0100

I indeed also noticed the memory leak upon many iterations. That is something to look into. But first for reproducing the crash: how can I start MATLAB 2010a in 32 bit mode? Oh... I already know. It might be that a bug was fixed but that the mexmaci was not recompiled to reflect the latest code changes. Some recent cleanups of the fieldtrip SVN directories and esp. the mex files make it difficult to track,


Robert Oostenveld - 2011-03-29 14:02:31 +0200

fixed in rev 3240


Robert Oostenveld - 2011-03-31 14:13:52 +0200

changed the status of most recently resolved/fixed bugs into "CLOSED"