MacOS – OSX 10.10 Python crashing from bash

bashcrashmacospython

When I run Python through bash it keeps seg faulting on me. The crash happens for example if I just type >>> "\n \n, but also for a lot of other cases. From my limited understanding of the stack trace, the problem is originating from readline.so. I've googled it but can't find anything mentioning this for Yosemite. It also doesn't appear to be an issue on any other Yosemite machines I've personally used.

Process:               Python [9000]
Path:                  /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier:            Python
Version:               2.7.3 (2.7.3)
Code Type:             X86-64 (Native)
Parent Process:        bash [8721]
Responsible:           Terminal [8717]
User ID:               501

Date/Time:             2015-01-29 06:27:11.243 +1000
OS Version:            Mac OS X 10.10.2 (14C106a)
Report Version:        11
Anonymous UUID:        96E040C2-750F-A04F-D83A-A4DDB5C2D113

Sleep/Wake UUID:       97B6A1FE-FCBF-40EB-9C2F-D98BF0B09893

Time Awake Since Boot: 420000 seconds
Time Since Wake:       420000 seconds

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

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000

VM Regions Near 0:
--> 
    __TEXT                 0000000100000000-0000000100001000 [    4K] r-x/rwx SM=COW  /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   readline.so                     0x00000001002eff97 call_readline + 647
1   org.python.python               0x0000000100008852 PyOS_Readline + 274
2   org.python.python               0x000000010000a0a8 tok_nextc + 104
3   org.python.python               0x000000010000a853 PyTokenizer_Get + 147
4   org.python.python               0x000000010000544a parsetok + 218
5   org.python.python               0x00000001000e7722 PyParser_ASTFromFile + 146
6   org.python.python               0x00000001000e8983 PyRun_InteractiveOneFlags + 243
7   org.python.python               0x00000001000e8c6e PyRun_InteractiveLoopFlags + 78
8   org.python.python               0x00000001000e9451 PyRun_AnyFileExFlags + 161
9   org.python.python               0x000000010010006d Py_Main + 3085
10  org.python.python               0x0000000100000f14 0x100000000 + 3860

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000100600000  rcx: 0x0000000100243620  rdx: 0x000000010023fa00
  rdi: 0x0000000000000000  rsi: 0x00000001002f0254  rbp: 0x00007fff5fbff5e0  rsp: 0x00007fff5fbff510
   r8: 0x0000000000000000   r9: 0x0000000000000001  r10: 0x0000000100600000  r11: 0x0000000000000001
  r12: 0x0000000000000001  r13: 0x000000000000000b  r14: 0x00007fff5fbff5a0  r15: 0x00007fff5fbff520
  rip: 0x00000001002eff97  rfl: 0x0000000000010206  cr2: 0x0000000000000000

Logical CPU:     6
Error Code:      0x00000004
Trap Number:     14


Binary Images:
       0x100000000 -        0x100000fff +org.python.python (2.7.3 - 2.7.3) <BE41DDF4-595E-0D6D-89DB-413749B339C3> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
       0x100003000 -        0x10016dff7 +org.python.python (2.7.3, [c] 2004-2012 Python Software Foundation. - 2.7.3) <4F9EF48A-7D0C-0C1A-670B-3BF4E72C8696> /Library/Frameworks/Python.framework/Versions/2.7/Python
       0x1002ee000 -        0x1002f0fff +readline.so (???) <A33567B3-2793-9387-FD19-41FFD86C18E5> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so
       0x1004b0000 -        0x1004cefff  libedit.2.dylib (40) <6049084C-478A-3A89-A9A1-E641B5F8C1A7> /usr/lib/libedit.2.dylib
    0x7fff6a4f2000 -     0x7fff6a528837  dyld (353.2.1) <65DCCB06-339C-3E25-9702-600A28291D0E> /usr/lib/dyld
    0x7fff80698000 -     0x7fff8070efe7  libcorecrypto.dylib (233.1.2) <E1789801-3985-3949-B736-6B3378873301> /usr/lib/system/libcorecrypto.dylib
    0x7fff8070f000 -     0x7fff8079bff7  libsystem_c.dylib (1044.10.1) <199ED5EB-77A1-3D43-AA51-81779CE0A742> /usr/lib/system/libsystem_c.dylib
    0x7fff807b7000 -     0x7fff807e2fff  libc++abi.dylib (125) <88A22A0F-87C6-3002-BFBA-AC0F2808B8B9> /usr/lib/libc++abi.dylib
    0x7fff8103c000 -     0x7fff81082ff7  libauto.dylib (186) <A260789B-D4D8-316A-9490-254767B8A5F1> /usr/lib/libauto.dylib
    0x7fff8149c000 -     0x7fff8149cff7  libunc.dylib (29) <5676F7EA-C1DF-329F-B006-D2C3022B7D70> /usr/lib/system/libunc.dylib
    0x7fff8149d000 -     0x7fff8149ffff  libsystem_configuration.dylib (699.1.5) <A2DF913B-501E-37D2-92B0-E835F671A47D> /usr/lib/system/libsystem_configuration.dylib
    0x7fff816b1000 -     0x7fff816c2ff7  libz.1.dylib (55) <88C7C7DE-04B8-316F-8B74-ACD9F3DE1AA1> /usr/lib/libz.1.dylib
    0x7fff816d0000 -     0x7fff816f8fff  libxpc.dylib (559.10.3) <9FDEE174-5229-363C-81D9-FC68274B13F6> /usr/lib/system/libxpc.dylib
    0x7fff81a16000 -     0x7fff81a1efff  libsystem_dnssd.dylib (561.1.1) <62B70ECA-E40D-3C63-896E-7F00EC386DDB> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff81b5b000 -     0x7fff81b77ff7  libsystem_malloc.dylib (53.1.1) <19BCC257-5717-3502-A71F-95D65AFA861B> /usr/lib/system/libsystem_malloc.dylib
    0x7fff81b78000 -     0x7fff81b7dff7  libmacho.dylib (862) <126CA2ED-DE91-308F-8881-B9DAEC3C63B6> /usr/lib/system/libmacho.dylib
    0x7fff81daf000 -     0x7fff81db4ff7  libsystem_stats.dylib (163.10.18) <9B8CCF24-DDDB-399A-9237-4BEC225D2E8C> /usr/lib/system/libsystem_stats.dylib
    0x7fff81e0f000 -     0x7fff81e47ffb  libsystem_network.dylib (411.1) <3F7BB564-AEC7-3EBA-8404-3718944F04A6> /usr/lib/system/libsystem_network.dylib
    0x7fff82c59000 -     0x7fff82c5bff7  libquarantine.dylib (76) <DC041627-2D92-361C-BABF-A869A5C72293> /usr/lib/system/libquarantine.dylib
    0x7fff83174000 -     0x7fff8317cfff  libsystem_platform.dylib (63) <64E34079-D712-3D66-9CE2-418624A5C040> /usr/lib/system/libsystem_platform.dylib
    0x7fff831f0000 -     0x7fff831fbfff  libcommonCrypto.dylib (60061) <D381EBC6-69D8-31D3-8084-5A80A32CB748> /usr/lib/system/libcommonCrypto.dylib
    0x7fff84223000 -     0x7fff84253fff  libsystem_m.dylib (3086.1) <1E12AB45-6D96-36D0-A226-F24D9FB0D9D6> /usr/lib/system/libsystem_m.dylib
    0x7fff84802000 -     0x7fff84804ff7  libsystem_coreservices.dylib (9) <41B7C578-5A53-31C8-A96F-C73E030B0938> /usr/lib/system/libsystem_coreservices.dylib
    0x7fff849bb000 -     0x7fff849c3ffb  libcopyfile.dylib (118.1.2) <0C68D3A6-ACDD-3EF3-991A-CC82C32AB836> /usr/lib/system/libcopyfile.dylib
    0x7fff85b2b000 -     0x7fff85b48fff  libsystem_kernel.dylib (2782.10.72) <97CD7ACD-EA0C-3434-BEFC-FCD013D6BB73> /usr/lib/system/libsystem_kernel.dylib
    0x7fff8626e000 -     0x7fff8626ffff  libSystem.B.dylib (1213) <5C161F1A-93BA-3221-A31D-F86222005B1B> /usr/lib/libSystem.B.dylib
    0x7fff86305000 -     0x7fff8630aff7  libunwind.dylib (35.3) <BE7E51A0-B6EA-3A54-9CCA-9D88F683A6D6> /usr/lib/system/libunwind.dylib
    0x7fff8632d000 -     0x7fff866c3fff  com.apple.CoreFoundation (6.9 - 1152) <CBD1591C-405E-376E-87E9-B264610EBF49> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7fff866c6000 -     0x7fff866f6ff7  libncurses.5.4.dylib (44) <F09809A4-53B9-3E91-A8FA-D3F584C03AA3> /usr/lib/libncurses.5.4.dylib
    0x7fff866f7000 -     0x7fff866fbfff  libcache.dylib (69) <45E9A2E7-99C4-36B2-BEE3-0C4E11614AD1> /usr/lib/system/libcache.dylib
    0x7fff877b3000 -     0x7fff877c9ff7  libsystem_asl.dylib (267) <F153AC5B-0542-356E-88C8-20A62CA704E2> /usr/lib/system/libsystem_asl.dylib
    0x7fff87d09000 -     0x7fff87d0aff7  libsystem_blocks.dylib (65) <9615D10A-FCA7-3BE4-AA1A-1B195DACE1A1> /usr/lib/system/libsystem_blocks.dylib
    0x7fff88544000 -     0x7fff88546ff7  libsystem_sandbox.dylib (358.1.1) <F395C6FD-7225-37AA-AB20-926B15A97C60> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff88547000 -     0x7fff88548fff  libDiagnosticMessagesClient.dylib (100) <2EE8E436-5CDC-34C5-9959-5BA218D507FB> /usr/lib/libDiagnosticMessagesClient.dylib
    0x7fff88b8d000 -     0x7fff88b93ff7  libsystem_networkextension.dylib (167.1.10) <29AB225B-D7FB-30ED-9600-65D44B9A9442> /usr/lib/system/libsystem_networkextension.dylib
    0x7fff88ea2000 -     0x7fff88eabfff  libsystem_pthread.dylib (105.10.1) <3103AA7F-3BAE-3673-9649-47FFD7E15C97> /usr/lib/system/libsystem_pthread.dylib
    0x7fff88eac000 -     0x7fff88ed6ff7  libdispatch.dylib (442.1.4) <502CF32B-669B-3709-8862-08188225E4F0> /usr/lib/system/libdispatch.dylib
    0x7fff8958e000 -     0x7fff89591ff7  libdyld.dylib (353.2.1) <29602A60-5AEC-39BE-8A2E-C4BBBD16706C> /usr/lib/system/libdyld.dylib
    0x7fff899ee000 -     0x7fff899ffff7  libsystem_coretls.dylib (35.1.2) <BC691CD1-17B6-39A5-BD02-AF973695FD1D> /usr/lib/system/libsystem_coretls.dylib
    0x7fff89b45000 -     0x7fff89b45ff7  libkeymgr.dylib (28) <77845842-DE70-3CC5-BD01-C3D14227CED5> /usr/lib/system/libkeymgr.dylib
    0x7fff8a0eb000 -     0x7fff8a0f2ff7  libcompiler_rt.dylib (35) <BF8FC133-EE10-3DA6-9B90-92039E28678F> /usr/lib/system/libcompiler_rt.dylib
    0x7fff8a3c9000 -     0x7fff8a3c9ff7  liblaunch.dylib (559.10.3) <659589CB-67FC-3C31-853B-F88332566CD1> /usr/lib/system/liblaunch.dylib
    0x7fff8a4e0000 -     0x7fff8a4e1ffb  libremovefile.dylib (35) <3485B5F4-6CE8-3C62-8DFD-8736ED6E8531> /usr/lib/system/libremovefile.dylib
    0x7fff8aedd000 -     0x7fff8af05fff  libsystem_info.dylib (459) <B85A85D5-8530-3A93-B0C3-4DEC41F79478> /usr/lib/system/libsystem_info.dylib
    0x7fff8b018000 -     0x7fff8b019fff  libsystem_secinit.dylib (18) <581DAD0F-6B63-3A48-B63B-917AF799ABAA> /usr/lib/system/libsystem_secinit.dylib
    0x7fff8b124000 -     0x7fff8b178fff  libc++.1.dylib (120) <1B9530FD-989B-3174-BB1C-BDC159501710> /usr/lib/libc++.1.dylib
    0x7fff8b7e1000 -     0x7fff8b9db46f  libobjc.A.dylib (647) <759E155D-BC42-3D4E-869B-6F57D477177C> /usr/lib/libobjc.A.dylib
    0x7fff8e538000 -     0x7fff8e71dff3  libicucore.A.dylib (531.31) <B08E00D5-13C6-3391-AB3A-8DE693D3B42E> /usr/lib/libicucore.A.dylib
    0x7fff8e71e000 -     0x7fff8e727ff7  libsystem_notify.dylib (133.1.1) <61147800-F320-3DAA-850C-BADF33855F29> /usr/lib/system/libsystem_notify.dylib
    0x7fff900c4000 -     0x7fff900cafff  libsystem_trace.dylib (72.1.3) <A9E6B7D8-C327-3742-AC54-86C94218B1DF> /usr/lib/system/libsystem_trace.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 1
    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: 22164753
    thread_create: 0
    thread_set_state: 117

VM Region Summary:
ReadOnly portion of Libraries: Total=84.0M resident=112.8M(134%) swapped_out_or_unallocated=16777216.0T(20949898362880%)
Writable regions: Total=28.7M written=2024K(7%) resident=4388K(15%) swapped_out=0K(0%) unallocated=24.4M(85%)

REGION TYPE                      VIRTUAL
===========                      =======
Kernel Alloc Once                     4K
MALLOC                             20.4M
MALLOC (admin)                       16K
STACK GUARD                        56.0M
Stack                              8192K
VM_ALLOCATE                           8K
__DATA                             1484K
__LINKEDIT                         70.9M
__TEXT                             13.1M
__UNICODE                           544K
shared memory                         4K
===========                      =======
TOTAL                             170.4M

Best Answer

I happened to notice that on a Yosemite machine where I spend a lot of time in the bash Python interpreter that it was running 2.7.8, as opposed to 2.7.3 which existed on this problematic computer.

Installing 2.7.8 from the Python website overwrite the old 2.7.3 and seems to have resolved the issue.