Page 1 of 1

SQLite Lib Crash

Posted: Thu Aug 21, 2003 8:44 pm
by Karbon
Hey El_Choni (or anyone else that knows), is it safe to use the SQLite userlib functions from inside a thread?

The SQlite guys tell me the windows DLL is compiled with -DTHREADSAFE by default so the library should be OK. The code below crashes big time on the first call of SQLiteExec() in the thread but is fine outside it.

For the database just a test table with three int fields will do.

Code: Select all

Procedure test_sqlite(go.l)
  
  Protected s_query.s
  
  For count = 1 To 10
    
    s_query.s = "INSERT INTO test values("+Str(Random(1000))+","+Str(Random(1000))+","+Str(Random(1000))+")"

    exec_result.l =  SQLiteExec(s_query)
  
    If exec_result <> 0 
    
      Debug SQLiteError(exec_result)
    
    EndIf
    
  Next
  
EndProcedure
 
init_result.l = InitSQLite("sqlite.dll")

If init_result = #False
  
  Debug "Initialize Failed "
  
  End
  
EndIf

Debug "SQLite Version: " + SQLiteDllVersion()

SQLiteOpen("ix.dat")

CreateThread(@test_sqlite(),1)

End
Thanks!

Posted: Fri Aug 22, 2003 1:49 am
by Karbon
The crash is triggered by the call to SQLiteError() inside the thread.. I also tried putting the SQLiteOpen("ix.dat") inside the thread itself but then it crashes on SQLiteOpen() :-(

*stares blankly at the ASM source*

Posted: Fri Aug 22, 2003 5:08 pm
by El_Choni
Can't help you right now, I'll fix it when I'm back to Spain, in September. Sorry for the inconvenience.

Regards,

Posted: Fri Aug 22, 2003 5:26 pm
by Karbon
Can you give me a hint as to what it might be - I'll have a go at fixing it :-)

I'm nowhere near good with ASM but I'm willing to try!

Thanks!

Posted: Sat Aug 30, 2003 9:25 pm
by El_Choni
My tip: implement Thread Local Storage in the lib XD (I was doing just exactly that before my holydays fell over my head). I would wait for September if I were you, but you can try yourself, it won't harm you.

Posted: Sun Aug 31, 2003 2:16 am
by Karbon
I'll wait for you to do it - that stuff is still a bit over my head!

Thanks !!!!

Posted: Mon Sep 15, 2003 6:57 pm
by Karbon
:-)

Posted: Tue Sep 16, 2003 10:15 am
by El_Choni
Haven't forgotten it, I'm moving this week, so I can't code right now ;)

Posted: Tue Sep 16, 2003 4:34 pm
by Karbon
Good luck with the move! :-)

Posted: Thu Oct 30, 2003 12:42 am
by Kale
Has this lib now been updated? where can i get the latest version?

Posted: Thu Oct 30, 2003 1:00 am
by Karbon
Not that I've heard.. If you find out please let me know!