PsychoPy/Python Malloc Error

OS : macOS High Sierra
PsychoPy version: v1.85.6
Standard Standalone? (y/n): y

We have an experiment that was created with Builder. It presents stimuli to participants in an fMRI scanner and he or she picks the left or right side of the screen. There is a code component that retrieves button presses from a DATAPixx3 device made by VPixx. We run the experiment with a MacBook Pro (2017). The DATAPixx3 is connected to the MacBook Pro through USB and display port. We use the Apple Digital AV USB-C adapter and a USB-C to Display Port adapter. The experiment worked well for the first 16 participants. Then, all of a sudden, the experiment crashed two times in a row. Each time, the error and macOS crash report was similar but the address space defined in the error message was a little different. We stopped scanning participants and are now running tests. The tests also crash. The error message and crash report are listed below. The crash report and error message are from two different runs of the experiment, hence the different address space. Also, the error message is from the console in Psychopy.

The laptop we use for the experiment is not used for anything else nor have we updated it. The staff at the MRI center have stated there has not been any wiring or hardware changes to their system. This is evident by the fact the experiment crashes on their test system as well as the stim system. Also, other researchers are not having any problems when using MatLab and the MRI center’s system. We have tried the following solutions: removing any instance of Python other than v2.7.12 that is found in the standalone version of PsychoPy, reinstalling the standalone version of Psychopy (1.85.6), checking the file system for errors, and using the MRI center’s tests system (which mirrors the system used for scanning).Today, we are going to reinstall macOS on the laptop and try a different laptop. We will also use a different USB-C to USB-A adapter. This issue just seems weird since the experiment has been flawless for the first 16 participants. We would appreciate any advice.

Error messages:

python (648,0x7fffa3da5380 malloc: ***error for object 0x136ba93f8: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

macOS crash report:

Process:               python [1714]
Path:                  /Applications/PsychoPy2.app/Contents/MacOS/python
Identifier:            org.psychopy.PsychoPy2
Version:               1.85.6 (0.0.0)
Code Type:             X86-64 (Native)
Parent Process:        PsychoPy2 [1662]
Responsible:           python [1714]
User ID:               501

Date/Time:             2018-05-25 14:20:03.655 -0700
OS Version:            Mac OS X 10.13.4 (17E199)
Report Version:        12
Anonymous UUID:        9D80FE40-A2E4-8481-1B6B-62A921B2A3F5


Time Awake Since Boot: 4900 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
abort() called
*** error for object 0x12c3e8638: pointer being freed was not allocated
 

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff51e36b6e __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff52001080 pthread_kill + 333
2   libsystem_c.dylib             	0x00007fff51d921ae abort + 127
3   libsystem_malloc.dylib        	0x00007fff51e90822 free + 521
4   org.python.python             	0x00000001000381cc PyFloat_ClearFreeList + 236
5   org.python.python             	0x000000010010784d _PyObject_GC_UnTrack + 2861
6   org.python.python             	0x0000000100107b1d _PyObject_GC_Malloc + 269
7   org.python.python             	0x0000000100107bd5 _PyObject_GC_New + 21
8   org.python.python             	0x000000010002be3c PyDescr_NewClassMethod + 2876
9   org.python.python             	0x00000001000741da PyType_IsSubtype + 5626
10  org.python.python             	0x00000001000c4449 PyEval_EvalFrameEx + 24457
11  org.python.python             	0x00000001000c9d23 PyEval_EvalCodeEx + 2115
12  org.python.python             	0x000000010003ef30 PyClassMethod_New + 800
13  org.python.python             	0x000000010000cd72 PyObject_Call + 98
14  org.python.python             	0x000000010001f52d PyInstance_NewRaw + 1101
15  org.python.python             	0x000000010000cd72 PyObject_Call + 98
16  org.python.python             	0x00000001000835aa PyType_Ready + 30394
17  org.python.python             	0x000000010008372b PyType_Ready + 30779
18  org.python.python             	0x000000010005c365 PyObject_SetAttr + 133
19  org.python.python             	0x00000001000bfb76 PyEval_EvalFrameEx + 5814
20  org.python.python             	0x00000001000c9d23 PyEval_EvalCodeEx + 2115
21  org.python.python             	0x000000010003ef30 PyClassMethod_New + 800
22  org.python.python             	0x000000010000cd72 PyObject_Call + 98
23  org.python.python             	0x000000010001f52d PyInstance_NewRaw + 1101
24  org.python.python             	0x000000010000cd72 PyObject_Call + 98
25  org.python.python             	0x00000001000835aa PyType_Ready + 30394
26  org.python.python             	0x00000001000c0880 PyEval_EvalFrameEx + 9152
27  org.python.python             	0x00000001000c9d23 PyEval_EvalCodeEx + 2115
28  org.python.python             	0x00000001000c6673 PyEval_EvalFrameEx + 33203
29  org.python.python             	0x00000001000c9d23 PyEval_EvalCodeEx + 2115
30  org.python.python             	0x00000001000c6673 PyEval_EvalFrameEx + 33203
31  org.python.python             	0x00000001000c9d23 PyEval_EvalCodeEx + 2115
32  org.python.python             	0x00000001000c9e46 PyEval_EvalCode + 54
33  org.python.python             	0x00000001000eecde PyRun_FileExFlags + 174
34  org.python.python             	0x00000001000eef7a PyRun_SimpleFileExFlags + 458
35  org.python.python             	0x000000010010614d Py_Main + 3101
36  python                        	0x0000000100000f14 0x100000000 + 3860

Thread 1:
0   libsystem_kernel.dylib        	0x00007fff51e36a1e __psynch_cvwait + 10
1   libsystem_pthread.dylib       	0x00007fff51fff589 _pthread_cond_wait + 732
2   interpreter.so                	0x0000000110d1d00b th_worker(void*) + 155
3   libsystem_pthread.dylib       	0x00007fff51ffe661 _pthread_body + 340
4   libsystem_pthread.dylib       	0x00007fff51ffe50d _pthread_start + 377
5   libsystem_pthread.dylib       	0x00007fff51ffdbf9 thread_start + 13

Thread 2:
0   libsystem_kernel.dylib        	0x00007fff51e36a1e __psynch_cvwait + 10
1   libsystem_pthread.dylib       	0x00007fff51fff589 _pthread_cond_wait + 732
2   interpreter.so                	0x0000000110d1d00b th_worker(void*) + 155
3   libsystem_pthread.dylib       	0x00007fff51ffe661 _pthread_body + 340
4   libsystem_pthread.dylib       	0x00007fff51ffe50d _pthread_start + 377
5   libsystem_pthread.dylib       	0x00007fff51ffdbf9 thread_start + 13

Thread 3:
0   libsystem_kernel.dylib        	0x00007fff51e36a1e __psynch_cvwait + 10
1   libsystem_pthread.dylib       	0x00007fff51fff589 _pthread_cond_wait + 732
2   interpreter.so                	0x0000000110d1d00b th_worker(void*) + 155
3   libsystem_pthread.dylib       	0x00007fff51ffe661 _pthread_body + 340
4   libsystem_pthread.dylib       	0x00007fff51ffe50d _pthread_start + 377
5   libsystem_pthread.dylib       	0x00007fff51ffdbf9 thread_start + 13

Thread 4:
0   libsystem_kernel.dylib        	0x00007fff51e36a1e __psynch_cvwait + 10
1   libsystem_pthread.dylib       	0x00007fff51fff589 _pthread_cond_wait + 732
2   interpreter.so                	0x0000000110d1d00b th_worker(void*) + 155
3   libsystem_pthread.dylib       	0x00007fff51ffe661 _pthread_body + 340
4   libsystem_pthread.dylib       	0x00007fff51ffe50d _pthread_start + 377
5   libsystem_pthread.dylib       	0x00007fff51ffdbf9 thread_start + 13

Thread 5:: com.apple.NSEventThread
0   libsystem_kernel.dylib        	0x00007fff51e2d20a mach_msg_trap + 10
1   libsystem_kernel.dylib        	0x00007fff51e2c724 mach_msg + 60
2   com.apple.CoreFoundation      	0x00007fff299dd7d5 __CFRunLoopServiceMachPort + 341
3   com.apple.CoreFoundation      	0x00007fff299dcb27 __CFRunLoopRun + 1783
4   com.apple.CoreFoundation      	0x00007fff299dc1a3 CFRunLoopRunSpecific + 483
5   com.apple.AppKit              	0x00007fff270b4fc4 _NSEventThread + 184
6   libsystem_pthread.dylib       	0x00007fff51ffe661 _pthread_body + 340
7   libsystem_pthread.dylib       	0x00007fff51ffe50d _pthread_start + 377
8   libsystem_pthread.dylib       	0x00007fff51ffdbf9 thread_start + 13

Thread 6:: org.libusb.device-hotplug
0   libsystem_kernel.dylib        	0x00007fff51e2d20a mach_msg_trap + 10
1   libsystem_kernel.dylib        	0x00007fff51e2c724 mach_msg + 60
2   com.apple.CoreFoundation      	0x00007fff299dd7d5 __CFRunLoopServiceMachPort + 341
3   com.apple.CoreFoundation      	0x00007fff299dcb27 __CFRunLoopRun + 1783
4   com.apple.CoreFoundation      	0x00007fff299dc1a3 CFRunLoopRunSpecific + 483
5   com.apple.CoreFoundation      	0x00007fff29a1ac33 CFRunLoopRun + 99
6   libdpx.dylib                  	0x000000012457d6f4 darwin_event_thread_main + 398
7   libsystem_pthread.dylib       	0x00007fff51ffe661 _pthread_body + 340
8   libsystem_pthread.dylib       	0x00007fff51ffe50d _pthread_start + 377
9   libsystem_pthread.dylib       	0x00007fff51ffdbf9 thread_start + 13

Thread 7:
0   libsystem_kernel.dylib        	0x00007fff51e37292 __workq_kernreturn + 10
1   libsystem_pthread.dylib       	0x00007fff51ffe009 _pthread_wqthread + 1035
2   libsystem_pthread.dylib       	0x00007fff51ffdbe9 start_wqthread + 13

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00007fff8a323380  rcx: 0x00007ffeefbfdbc8  rdx: 0x0000000000000000
  rdi: 0x0000000000000307  rsi: 0x0000000000000006  rbp: 0x00007ffeefbfdc00  rsp: 0x00007ffeefbfdbc8
   r8: 0x0000000000000000   r9: 0x0000000000000000  r10: 0x0000000000000000  r11: 0x0000000000000206
  r12: 0x0000000000000307  r13: 0x0000000000000004  r14: 0x0000000000000006  r15: 0x000000000000002d
  rip: 0x00007fff51e36b6e  rfl: 0x0000000000000206  cr2: 0x00007fff8a300168
  
Logical CPU:     0
Error Code:      0x02000148
Trap Number:     133


Binary Images:
       0x100000000 -        0x100000fff +python (???) <C2055A43-D803-3CC5-FFF0-363A42F24F4E> /Applications/PsychoPy2.app/Contents/MacOS/python
       0x100003000 -        0x100175ff7 +org.python.python (2.7.12, [c] 2001-2016 Python Software Foundation. - 2.7.12) <831DC7C1-B842-23D7-69C8-73A7D5E5574C> /Applications/PsychoPy2.app/Contents/Frameworks/Python.framework/Versions/2.7/Python
       [...]
       0x11dc3b000 -        0x11dc43fff  com.apple.iokit.IOUSBLib (900.4.1 - 900.4.1) <34997286-B357-3189-B58C-83C33FA37917> /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/IOUSBLib.bundle/Contents/MacOS/IOUSBLib
       0x11e466000 -        0x11e47cff7 +com.xrite.i1d3SDK (1.4.0 - 9515) <55C1E14B-86D1-3DE6-A89F-03874C2893E4> /Library/Frameworks/i1d3SDK.framework/Versions/A/i1d3SDK
       0x124500000 -        0x12458bfff +libdpx.dylib (0) <A9FB35F3-652A-3A66-998C-802A160129EA> /Library/Python/2.7/site-packages/pypixxlib/lib/mac/libdpx.dylib
       0x12865f000 -        0x128899fff +com.xrite.i1Pro (4.2.2 - 4714) <DBB33CA7-5FDF-331D-B092-B263B9AE8E94> /Library/Frameworks/i1Pro.framework/Versions/A/i1Pro
	[...]
    0x7fff51e8d000 -     0x7fff51eacfff  libsystem_malloc.dylib (140.50.6) <7FD43735-9DDD-300E-8C4A-F909A74BDF49> /usr/lib/system/libsystem_malloc.dylib
    0x7fff51ead000 -     0x7fff51fddff3  libsystem_network.dylib (1229.51.2) <F65ED095-8ABA-3355-93F8-B9D0505932F4> /usr/lib/system/libsystem_network.dylib
    0x7fff51fde000 -     0x7fff51fe8ffb  libsystem_networkextension.dylib (767.50.25) <758F1414-796D-3422-83C9-92D2915A06CE> /usr/lib/system/libsystem_networkextension.dylib
    0x7fff51fe9000 -     0x7fff51ff2ff3  libsystem_notify.dylib (172) <08012EC0-2CD2-34BE-BF93-E7F56491299A> /usr/lib/system/libsystem_notify.dylib
    0x7fff51ff3000 -     0x7fff51ffaff7  libsystem_platform.dylib (161.50.1) <6355EE2D-5456-3CA8-A227-B96E8F1E2AF8> /usr/lib/system/libsystem_platform.dylib
    0x7fff51ffb000 -     0x7fff52006fff  libsystem_pthread.dylib (301.50.1) <0E51CCBA-91F2-34E1-BF2A-FEEFD3D321E4> /usr/lib/system/libsystem_pthread.dylib
    0x7fff52007000 -     0x7fff5200afff  libsystem_sandbox.dylib (765.50.51) <B48D256E-D7DB-3D4F-BC95-34557170C7AA> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff5200b000 -     0x7fff5200cff3  libsystem_secinit.dylib (30) <DE8D14E8-A276-3FF8-AE13-77F7040F33C1> /usr/lib/system/libsystem_secinit.dylib
    0x7fff5200d000 -     0x7fff52014ff7  libsystem_symptoms.dylib (820.50.37) <ED7350E0-B68B-374A-9AB7-DC1F195A8327> /usr/lib/system/libsystem_symptoms.dylib
    0x7fff52015000 -     0x7fff52028fff  libsystem_trace.dylib (829.50.17) <6568D68B-1D4C-38EE-90A9-54821D6403C0> /usr/lib/system/libsystem_trace.dylib
    0x7fff5202a000 -     0x7fff5202fff7  libunwind.dylib (35.3) <BEF3FB49-5604-3B5F-82B5-332B80023AC3> /usr/lib/system/libunwind.dylib
    0x7fff52030000 -     0x7fff5205dfff  libxpc.dylib (1205.50.76) <25DB244E-217D-3CE0-A8F2-0C4255783B42> /usr/lib/system/libxpc.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 90
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 101516
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=531.6M resident=0K(0%) swapped_out_or_unallocated=531.6M(100%)
Writable regions: Total=382.2M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=382.2M(100%)
 
                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Accelerate framework               128K        2 
Activity Tracing                   256K        2 
CG backing stores                 1928K        7 
CG image                          1032K        3 
CG raster data                     172K       10 
CoreGraphics                         8K        2 
CoreImage                           32K        5 
CoreUI image data                  512K        5 
CoreUI image file                  180K        4 
Dispatch continuations            8192K        2 
Kernel Alloc Once                    8K        2 
MALLOC                           290.1M      189 
MALLOC guard page                   48K       13 
Memory Tag 242                      12K        2 
OpenGL GLSL                        256K        4 
STACK GUARD                       56.0M        9 
Stack                             11.6M        9 
VM_ALLOCATE                        576K       34 
__DATA                           106.7M      535 
__FONT_DATA                          4K        2 
__GLSLBUILTINS                    2588K        2 
__LINKEDIT                       206.6M      188 
__TEXT                           325.1M      495 
__UNICODE                          560K        2 
mapped file                      178.9M       52 
shared memory                      764K       20 
===========                     =======  ======= 
TOTAL                              1.2G     1574 

Model: MacBookPro14,1, BootROM MBP141.0173.B00, 2 processors, Intel Core i5, 2.3 GHz, 16 GB, SMC 2.43f6
Graphics: Intel Iris Plus Graphics 640, Intel Iris Plus Graphics 640, Built-In
Memory Module: BANK 0/DIMM0, 8 GB, LPDDR3, 2133 MHz, 0x802C, 0x4D5435324C31473332443450472D30393320
Memory Module: BANK 1/DIMM0, 8 GB, LPDDR3, 2133 MHz, 0x802C, 0x4D5435324C31473332443450472D30393320
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x170), Broadcom BCM43xx 1.0 (7.77.37.29.1a7)
Bluetooth: Version 6.0.5f3, 3 services, 27 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB 3.0 Bus
USB Device: PTN5002
USB Device: USB2.0 Hub
USB Device: USB2.0 Hub
USB Device: DATAPixx3
USB Device: USB
USB Device: USB-C Digital AV Multiport Adapter
USB Device: USB3.0 Hub
Thunderbolt Bus: MacBook Pro, Apple Inc., 33.1

That code doesn’t use threads or anything unusual does it?

Michael,

Thank you for your reply. No, the code associated with the DATAPixx3 does not use threads. The DATAPixx3 has it’s own clock and timestamps all data and logs the events into the DATAPIxx3 device. The Psychopy experiment uses DATAPIxx3 python libraries to retrieve the logs and read it. This happens at 120Hz since the projector and monitor connected to the DATAPixx3 is 120Hz.

Again, thank you for your time. I appreciate it.

OS : OSX El Capitan
PsychoPy version: v1.85.2
Standard Standalone? (y/n): y

I’m having this issue too, with a Builder experiment that used to work fine. I have not changed the experiment code, the PsychoPy version, or anything Python-related on the machine. There is nothing fancy in this experiment, in fact it’s just a demo for teaching PsychoPy to new lab members (so there is an image component, a sound component and a couple of text components).

When I remove the one sound component in the experiment, it works fine and I don’t get the error. But again there’s nothing fancy about that sound component. Other experiments with sound components are working fine.

I tried re-building the simple demo from scratch and encountered the same error. If anyone has any insights I’d be grateful!

python(15823,0x7fff78e8c000) malloc: *** error for object 0x111e91b70: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug