MacOS – How to debug Trace/BPT trap: 5

macosterminal

I get a Trace/BPT trap: 5 error when using the open command:

$ open -a Emacs
Trace/BPT trap: 5
$ open -a Safari 
Trace/BPT trap: 5
$ open -a TextEdit
Trace/BPT trap: 5

Any suggestions how I can narrow down what is causing this?

I understand from my earlier question, that it has to do with not finding a dynamic library – but which one and why is it not finding the library?

Fron the GUI, everything works fine, but is present from termnal as well as iTerm.

System: Macbook Pro Retina, Maverick

Any suggestions?

ADDITIONAL INFO:

$ otool -L /Applications/TextEdit.app/Contents/MacOS/TextEdit
/Applications/TextEdit.app/Contents/MacOS/TextEdit:
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 20.0.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1056.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 59.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 855.11.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1251.0.0)
/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 600.0.0)

and

$ otool -L /Applications/Emacs.app/Contents/MacOS/Emacs-10.7 
/Applications/Emacs.app/Contents/MacOS/Emacs-10.7:
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1138.47.0)
/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.3.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 53.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.21.0)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 41.0.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 833.25.0)

so I can't see anything missing?

Best Answer

I suspect you will by now have seen the problem reappear. The fix you described had a side-effect that ended up, for a time, solving the problem.

I believe that the problem had to do with the security context in which your terminal's shell was attempting to launch programs that try to connect to the window system.

My solution to this problem, whenever it has occurred from my Terminal.app shells, has been to use reattach-to-user-namespace (https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard). For example, at a bash prompt:

tk-mbp:~ tommy$ wstorm Projects/my-webapp
Trace/BPT trap: 5
tk-mbp:~ tommy$ exec reattach-to-user-namespace -l bash
(reading ~/.bash_profile)
tk-mbp:~ tommy$ wstorm Projects/my-webapp
tk-mbp:~ tommy$ # that worked...

When you rebooted as part of the fix you reported, it had the side-effect of creating a shell process whose connection to the security context of your windowed login session was not stale, as it had been before when the commands were failing with "Trace/BPT trap: 5". So although there might have been a real problem with the PATH setup, I believe it was the refreshing of the shell's process environment that was the true fix.

FWIW, I've got reattach-to-user-namespace installed via Homebrew.