Hard crash in SQLitePreparedStatement

I’ve now got a second user who is having hard crashes when writing to an SQLite database with the following code:

[code] if thePrepared = Nil then
thePrepared = SQLiteIndexDB.Prepare(“INSERT INTO bodyindex(docid, messagebody) VALUES(?, ?)”)
thePrepared.BindType(0, SQLitePreparedStatement.SQLITE_INTEGER)
thePrepared.BindType(1, SQLitePreparedStatement.SQLITE_TEXT)

end if

thePrepared.SQLExecute(theRecID, MessageBody)

[/code]
The database is a dataless one. There is only an index which I use for text search in a Valentina database.

Xojo 2017r1, macOS 10.12 and 10.13.

Does anyone have an idea what might cause this? Is the malloc again an indication that this is memory related?

Crash log:

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000007265
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Bus error: 10
Termination Reason: Namespace SIGNAL, Code 0xa
Terminating Process: exc handler [0]

VM Regions Near 0x7265:
–> __TEXT 0000000000001000-0000000001bd8000 [ 27.8M] r-x/rwx SM=COW /Applications/Mail Archiver X/Mail Archiver X.app/Contents/MacOS/Mail Archiver X
__DATA 0000000001bd8000-0000000001c82000 [ 680K] rw-/rwx SM=COW /Applications/Mail Archiver X/Mail Archiver X.app/Contents/MacOS/Mail Archiver X

Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0xa761dd6e __psynch_cvwait + 10
1 libsystem_pthread.dylib 0xa774c4eb _pthread_cond_wait + 658
2 libsystem_pthread.dylib 0xa774e140 pthread_cond_wait$UNIX2003 + 51
3 com.xojo.XojoFramework 0x0239c4b1 0x2307000 + 611505
4 com.xojo.XojoFramework 0x024c50be 0x2307000 + 1827006
5 com.xojo.XojoFramework 0x024c2f31 0x2307000 + 1818417
6 com.xojo.XojoFramework 0x02348ce6 0x2307000 + 269542
7 com.apple.CoreFoundation 0x93907ab3 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 19
8 com.apple.CoreFoundation 0x93907628 __CFRunLoopDoTimer + 1224
9 com.apple.CoreFoundation 0x9390709b __CFRunLoopDoTimers + 395
10 com.apple.CoreFoundation 0x938fecdb __CFRunLoopRun + 3211
11 com.apple.CoreFoundation 0x938fdd21 CFRunLoopRunSpecific + 641
12 com.apple.CoreFoundation 0x938fda8a CFRunLoopRunInMode + 122
13 com.apple.HIToolbox 0x92efed4b RunCurrentEventLoopInMode + 321
14 com.apple.HIToolbox 0x92efea72 ReceiveNextEventCommon + 777
15 com.apple.HIToolbox 0x92efe74b _BlockUntilNextEventMatchingListInModeWithFilter + 71
16 com.apple.AppKit 0x91358839 _DPSNextEvent + 2101
17 com.apple.AppKit 0x91ac9838 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2859
18 com.apple.AppKit 0x91ac8d05 -[NSApplication(NSEvent) nextEventMatchingMask:untilDate:inMode:dequeue:] + 134
19 com.xojo.XojoFramework 0x02348c7b 0x2307000 + 269435
20 com.xojo.XojoFramework 0x02348cc4 0x2307000 + 269508
21 com.mothsoftware.mailarchiverx 0x001f92a7 Delegate.Invoke%% + 34
22 com.mothsoftware.mailarchiverx 0x00099efb Application._CallFunctionWithExceptionHandling%%op + 248
23 com.xojo.XojoFramework 0x024b5d4a 0x2307000 + 1764682
24 com.xojo.XojoFramework 0x02348c1c 0x2307000 + 269340
25 com.apple.AppKit 0x9134d775 -[NSApplication run] + 763
26 com.xojo.XojoFramework 0x024b5dea 0x2307000 + 1764842
27 com.xojo.XojoFramework 0x024b3fc4 RuntimeRun + 49
28 com.mothsoftware.mailarchiverx 0x001ad4f0 REALbasic._RuntimeRun + 34
29 com.mothsoftware.mailarchiverx 0x0195aaa2 _Main + 295
30 com.mothsoftware.mailarchiverx 0x01954bec main + 36
31 com.mothsoftware.mailarchiverx 0x01a1931f start + 53

Thread 1:
0 libsystem_kernel.dylib 0xa761dd6e __psynch_cvwait + 10
1 libsystem_pthread.dylib 0xa774c4eb _pthread_cond_wait + 658
2 libsystem_pthread.dylib 0xa774e140 pthread_cond_wait$UNIX2003 + 51
3 libc++.1.dylib 0xa59a8669 std::__1::condition_variable::wait(std::__1::unique_lockstd::__1::mutex&) + 39
4 com.apple.JavaScriptCore 0x967770ca void std::__1::condition_variable_any::wait<std::__1::unique_lockbmalloc::Mutex >(std::__1::unique_lockbmalloc::Mutex&) + 90
5 com.apple.JavaScriptCore 0x96776fec bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::)()>::threadRunLoop() + 124
6 com.apple.JavaScriptCore 0x9677737f void
std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_deletestd::__1::__thread_struct >, void ()(bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::)()>), bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::)()>> >(void) + 47
7 libsystem_pthread.dylib 0xa774b51d _pthread_body + 347
8 libsystem_pthread.dylib 0xa774b3c2 _pthread_start + 357
9 libsystem_pthread.dylib 0xa774aa9e thread_start + 34

Thread 2:: com.apple.NSEventThread
0 libsystem_kernel.dylib 0xa7614d22 mach_msg_trap + 10
1 libsystem_kernel.dylib 0xa761435f mach_msg + 47
2 com.apple.CoreFoundation 0x938ff938 __CFRunLoopServiceMachPort + 296
3 com.apple.CoreFoundation 0x938fe926 __CFRunLoopRun + 2262
4 com.apple.CoreFoundation 0x938fdd21 CFRunLoopRunSpecific + 641
5 com.apple.CoreFoundation 0x938fda8a CFRunLoopRunInMode + 122
6 com.apple.AppKit 0x91488505 _NSEventThread + 165
7 libsystem_pthread.dylib 0xa774b51d _pthread_body + 347
8 libsystem_pthread.dylib 0xa774b3c2 _pthread_start + 357
9 libsystem_pthread.dylib 0xa774aa9e thread_start + 34

Thread 3:
0 libsystem_kernel.dylib 0xa761e71a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0xa774b0a0 _pthread_wqthread + 1536
2 libsystem_pthread.dylib 0xa774aa7a start_wqthread + 34

Thread 4 Crashed:
0 com.xojo.XojoFramework 0x02395ca9 0x2307000 + 584873
1 com.xojo.XojoFramework 0x0238961d 0x2307000 + 534045
2 com.xojo.XojoFramework 0x024c20b4 RuntimeUnlockString + 34
3 SQLiteDatabase.dylib 0x09306f39 0x9300000 + 28473
4 SQLiteDatabase.dylib 0x0930ade7 0x9300000 + 44519
5 SQLiteDatabase.dylib 0x0930b4b7 0x9300000 + 46263
6 SQLiteDatabase.dylib 0x0930a940 0x9300000 + 43328
7 com.mothsoftware.mailarchiverx 0x00143bf1 SQLitePreparedStatement.*SQLExecute%%oA1v + 72
8 com.mothsoftware.mailarchiverx 0x01592d46 SQLiteIndex.Write%%oi4s + 784
9 com.mothsoftware.mailarchiverx 0x00ec0793 MailParser.parse%i4%o + 10266
10 com.mothsoftware.mailarchiverx 0x00e5e751 ArchiveThread.Archive%%o + 11067
11 com.mothsoftware.mailarchiverx 0x00e59159 ArchiveThread.Event_Run%%o + 79
12 com.xojo.XojoFramework 0x024c434d 0x2307000 + 1823565
13 com.xojo.XojoFramework 0x0239c246 0x2307000 + 610886
14 libsystem_pthread.dylib 0xa774b51d _pthread_body + 347
15 libsystem_pthread.dylib 0xa774b3c2 _pthread_start + 357
16 libsystem_pthread.dylib 0xa774aa9e thread_start + 34

Thread 5:
0 libsystem_kernel.dylib 0xa761e71a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0xa774aeab _pthread_wqthread + 1035
2 libsystem_pthread.dylib 0xa774aa7a start_wqthread + 34

Thread 6:
0 libsystem_kernel.dylib 0xa761e71a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0xa774b0a0 _pthread_wqthread + 1536
2 libsystem_pthread.dylib 0xa774aa7a start_wqthread + 3

When you say “dataless”, do you mean that it is in-memory?

Nope. Just an index and no data. This is the SQL for the table creation:

CREATE VIRTUAL TABLE bodyindex USING fts4(content='', messagebody);

Bump. Any ideas anyone?

if thePrepared = Nil then
    thePrepared = SQLiteIndexDB.Prepare("INSERT INTO bodyindex(docid, messagebody) VALUES(?, ?)")
    thePrepared.BindType(0, SQLitePreparedStatement.SQLITE_INTEGER)
    thePrepared.BindType(1, SQLitePreparedStatement.SQLITE_TEXT)
    
  end if
  
    thePrepared.SQLExecute(theRecID, MessageBody)

Based on your example, you expect “thePrepared” to possiblly be NIL at times?
If so, if and when it is, you are still attempting to Execute that statement

other possiblity of course is that SQLiteIndexDB is also NIL to begin with

The SQLite code is in a singleton. The prepared statement is created the first time the code is executed. I would have noticed a NOE.

The crash is NOT memory related - at least I can’t see any memory leak. From what I have seen the crashes come after a couple of thousand added records.