Skip to content

Conversation

@gabe-l-hart
Copy link
Collaborator

Description

In my development environment on MacOS, any time I hit a failing GGML_ASSERT, my entire Terminal.app crashes (all windows, all processes, not just the ones involving the failing binary). I traced this down to the attempt to use lldb to print out a backtrace here.

The simplest fix is simply setting GGML_NO_BACKTRACE in the environment, but this is unset by default and needs to be discovered. It also needs to either be set in a global .bash_profile or set on every terminal.

This PR adds an __APPLE__-specific code path that uses the native backtrace() function and avoids attempting to attach to the parent from the forked lldb process.

Testing

To repro this, add a failing GGML_ASSERT somewhere, for example:

diff --git a/tests/test-log.cpp b/tests/test-log.cpp
index 306f28c61..b21e60cd6 100644
--- a/tests/test-log.cpp
+++ b/tests/test-log.cpp
@@ -6,6 +6,8 @@
 int main() {
     const int n_thread = 8;
 
+    GGML_ASSERT(false);
+
     std::thread threads[n_thread];
     for (int i = 0; i < n_thread; i++) {
         threads[i] = std::thread([i]() {

Once built, run it and hit the assert:

./bin/test-log

Sources

(Found with the help of Claude Code)

Branch: MacOSSafeBacktrace

Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
@gabe-l-hart gabe-l-hart added ggml changes relating to the ggml tensor library for machine learning macos Issues specific to macOS bugfix fixes an issue or bug labels Dec 8, 2025
@gabe-l-hart
Copy link
Collaborator Author

@ggerganov Is there a good macos specialist to look at this one?

@ggerganov
Copy link
Member

The lldb backtrace is a bit more informative, so I prefer to keep it:

  • By default, print the native backtrace as you propose
  • Also print a message that for extra debug info, set env GGML_BACKTRACE_LLDB=1
  • If the env is set, use lldb to attach (i.e. what we currently do on master)

@gabe-l-hart
Copy link
Collaborator Author

@ggerganov I think that makes sense. Have you (or any other MacOS users) observed this behavior? It looks like this has something to do with the interaction of lldb and certain MacOS versions and has been an open issue since at least 2022. Basically, I'm curious if there are any current MacOS versions where this doesn't happen (I'd assume so since I haven't found any issues mentioning this).

@ggerganov
Copy link
Member

@gabe-l-hart Terminal.app crashes on my machines the same way as you described. However, I never use it. Just switch to some other terminal emulator and it should be good.

Branch: MacOSSafeBacktrace

Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
@gabe-l-hart
Copy link
Collaborator Author

Makes sense! For some unexplainable reason, I've always resisted non-standard terminals (we programmers are a strange bunch), but I'm glad it's only a problem with Terminal.app. I've updated with the GGML_BACKTRACE_LLDB env var as suggested.

@ggerganov ggerganov merged commit 02e409a into ggml-org:master Dec 9, 2025
69 checks passed
@gabe-l-hart gabe-l-hart deleted the MacOSSafeBacktrace branch December 9, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix fixes an issue or bug ggml changes relating to the ggml tensor library for machine learning macos Issues specific to macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants