Skip to content

Commit 258e232

Browse files
author
Daniele Briggi
committed
chore(makefile): investigate segmentation fault
1 parent 7062f9a commit 258e232

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

.github/workflows/main.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,37 @@ jobs:
152152
if: matrix.name == 'macos'
153153
run: |
154154
echo "Checking if whisper CoreML symbols are present..."
155-
nm -D dist/ai.dylib | grep -i coreml || echo "CoreML symbols not found in binary"
155+
echo "=== Dynamic symbols in ai.dylib ==="
156+
nm -D dist/ai.dylib | grep -i coreml || echo "CoreML symbols not found in dynamic symbol table"
157+
echo "=== All symbols in ai.dylib ==="
158+
nm dist/ai.dylib | grep -i coreml || echo "CoreML symbols not found in symbol table"
159+
echo "=== Linked frameworks ==="
156160
otool -L dist/ai.dylib | grep CoreML || echo "CoreML framework not linked"
157-
nm build/whisper.cpp/src/libwhisper.a | grep coreml
158-
nm build/whisper.cpp/src/libwhisper.coreml.a | grep coreml
161+
echo "=== CoreML symbols in whisper libraries ==="
162+
nm build/whisper.cpp/src/libwhisper.a | grep coreml || echo "No CoreML symbols in libwhisper.a"
163+
nm build/whisper.cpp/src/libwhisper.coreml.a | grep coreml || echo "No CoreML symbols in libwhisper.coreml.a"
164+
165+
- name: test sqlite-ai with crash debugging (macOS)
166+
if: matrix.name == 'macos'
167+
run: |
168+
echo "=== Testing with crash debugging ==="
169+
# Enable core dumps
170+
ulimit -c unlimited
171+
# Run with detailed crash info
172+
echo "Running test with lldb to capture crash info..."
173+
echo "run" | lldb -- sqlite3 ":memory:" -cmd ".bail on" ".load ./dist/ai" "SELECT ai_version();" || {
174+
echo "Test failed, checking for core dump..."
175+
if [ -f core.* ]; then
176+
echo "Core dump found, analyzing..."
177+
echo "bt" | lldb -c core.* sqlite3
178+
fi
179+
# Also try with crash reporter
180+
echo "Checking system crash logs..."
181+
log show --predicate 'eventMessage contains "sqlite3"' --info --last 1m || true
182+
}
183+
# Also try running the test directly to see if it works
184+
echo "=== Direct test run ==="
185+
sqlite3 ":memory:" -cmd ".bail on" ".load ./dist/ai" "SELECT ai_version();" || echo "Direct test also failed"
159186
160187
- name: test sqlite-ai
161188
if: matrix.name == 'linux' || matrix.name == 'macos'

src/sqlite-ai.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
#include <stdlib.h>
2525
#include <string.h>
2626

27+
#ifdef __APPLE__
28+
#import <Foundation/Foundation.h>
29+
#endif
30+
2731
#ifndef SQLITE_CORE
2832
SQLITE_EXTENSION_INIT1
2933
#endif
@@ -1947,7 +1951,18 @@ SQLITE_AI_API int sqlite3_ai_init (sqlite3 *db, char **pzErrMsg, const sqlite3_a
19471951
// initialize the llama + ggml backend
19481952
static bool once = false;
19491953
if (once == false) {
1954+
// On macOS, llama_backend_init() can cause issues with CoreML initialization
1955+
// Add safety check to prevent crashes
1956+
#ifdef __APPLE__
1957+
@try {
1958+
llama_backend_init();
1959+
} @catch (NSException *exception) {
1960+
if (pzErrMsg) *pzErrMsg = sqlite3_mprintf("Failed to initialize LLAMA backend: %s", [exception.description UTF8String]);
1961+
return SQLITE_ERROR;
1962+
}
1963+
#else
19501964
llama_backend_init();
1965+
#endif
19511966
once = true;
19521967
}
19531968

0 commit comments

Comments
 (0)