|Summary:||Broken gdb with Apple's macOS 10.12 Sierra Beta - SIGTRAP|
|Component:||gdb||Assignee:||Not yet assigned to anyone <unassigned>|
|Severity:||normal||CC:||antonio.luis.sarmento, art29577, josh, palves, simon, sourceware, tromey, xdavidliu|
|Build:||Last reconfirmed:||2018-06-27 00:00:00|
|Attachments:||my terminal session leading up to an error|
Description nikolaikrill 2016-06-16 22:42:06 UTC
Just tried out Apple's new beta of the next version of OS X, namely macOS 10.12 Sierra. A freshly compiled gdb 7.11.1 is not capable of debugging anything I've tried yet, it always fails with: During startup program terminated with signal SIGTRAP, Trace/breakpoint trap. This is an issue specific to macOS 10.12 beta, the same gdb works fine under Mac OS X 10.11. I'm not sure if this is an Apple issue or one with gdb, just thought I should let you guys know. Also, lldb is working fine on macOS 10.12, so there's that. (gdb) run Starting program: /Users/k/Desktop/gdb-test/test_program During startup program terminated with signal SIGTRAP, Trace/breakpoint trap. (gdb)
Comment 1 antonio.luis.sarmento 2016-09-23 13:01:53 UTC
So, the official, final release of Sierra is here and I'm here (alongside another user) to confirm this problem exists and should be treated *ASAP! Link to my recently-created thread on Reddit: https://www.reddit.com/r/learnprogramming/comments/53zmls/gdb_itself_is_crashing_and_i_cant_seem_to_find_a/d7xs95g?context=3
Comment 2 Pedro Alves 2016-09-23 19:15:03 UTC
Unfortunately, I don't think that any active maintainer uses macOS routinely. So this likely will only get fixed when someone contributes a fix or investigates what the problem is.
Comment 3 Pedro Alves 2016-09-23 19:19:32 UTC
Note that "During startup program terminated..." indicates that it's the shell that died. GDB starts the program like "sh -c '$program $arg1 $arg2'". Usually, on Unix systems, gdb will see one SIGTRAP that indicates that the shell execed the final program, and so gdb is now actually debugging the program. Maybe the problems is that now on macOS gdb needs to expect two traps. See the START_INFERIOR_TRAPS_EXPECTED define in gdb's sources. Try bumping it. But first try the "set startup-with-shell off" command.
Comment 4 nikolaikrill 2016-10-06 18:32:38 UTC
(In reply to Pedro Alves from comment #3) > Note that "During startup program terminated..." indicates that it's the > shell that died. GDB starts the program like "sh -c '$program $arg1 $arg2'". > > Usually, on Unix systems, gdb will see one SIGTRAP that indicates that the > shell execed the final program, and so gdb is now actually debugging the > program. > > Maybe the problems is that now on macOS gdb needs to expect two traps. > > See the START_INFERIOR_TRAPS_EXPECTED define in gdb's sources. Try bumping > it. > > But first try the "set startup-with-shell off" command. Thanks for your input, Pedro. I've tried both of your suggestions, but the problem still persists. What's strange is that the problem was fixed when I tried using gdb in Apple's later betas of Sierra, but then the issue reappeared in the official public release. Now, though, the error message has changed to the following: During startup program terminated with signal SIG113, Real-time event 113. I've also verified that the problem exists on macOS 10.12.1 Beta 3 (Build 16B2338c). The issue appears to be affecting everybody using gdb on Sierra, and threads on the topic have started appearing on Stack Overflow and other forums, but nobody seems to have solution yet.
Comment 5 Pedro Alves 2016-10-14 16:12:47 UTC
Seems like someone found a workaround: https://sourceware.org/ml/gdb/2016-10/msg00009.html
Comment 6 Tom Tromey 2016-11-01 03:40:40 UTC
This seems to hold the answer: https://sourceware.org/ml/gdb/2016-10/msg00062.html
Comment 7 Tom Tromey 2016-11-11 17:13:29 UTC
A partial fix went in: https://sourceware.org/ml/gdb/2016-11/msg00011.html But apparently it still needs "set startup-with-shell off"
Comment 8 art29577 2018-02-09 18:09:22 UTC
This fix doesn't work for me on 10.13.3, I get exact same error message with gdb 8.1..
Comment 9 art29577 2018-02-09 19:38:37 UTC
Created attachment 10799 [details] my terminal session leading up to an error See more details in the attachment
Comment 10 xdavidliu 2018-03-13 19:12:33 UTC
art29577 for high sierra this error actually only occurs for 8.1. If you downgrade to 8.0.1 using brew, this issue goes away. Assuming codesigning is done correctly (which is a whole nother unrelated can of worms, the only hiccup in 8.0.1 would be a warning about dyld version, but gdb 8.0.1 works correctly). whatever re-introduced the sig/breakpoint trap that occurred in your terminal output happened between 8.0.1 and 8.1, and should be filed as a new bug, not a continuation of this one from 2016.
Comment 11 xdavidliu 2018-03-13 19:34:45 UTC
by the way, to downgrade from 8.1 to 8.0.1, see the answer to this question: https://stackoverflow.com/questions/49001329/gdb-doesnt-work-on-macos-high-sierra-10-13-3#comment85498442_49001329 The fact that the problem seen in art29577 's terminal session goes away after downgrading to 8.0.1 suggests to me that this is a newer problem, introduced sometime between 8.0.1 and 8.1, *not* the one originally in this thread, which goes back to 6/2016. I have filed a new bug report at bug # 22960.
Comment 12 m.gh0stzer0 2018-06-24 15:33:54 UTC
Unable to find Mach task port for process-id 37095: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))
Comment 13 Tom Tromey 2018-06-27 22:25:10 UTC
Neither 8.0.1 nor git master work for me on macOS 10.13.5.