SQLite Lib Crash

Everything else that doesn't fall into one of the other PB categories.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

SQLite Lib Crash

Post 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!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post 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*
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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,
El_Choni
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post 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!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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.
El_Choni
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

I'll wait for you to do it - that stuff is still a bit over my head!

Thanks !!!!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

:-)
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Haven't forgotten it, I'm moving this week, so I can't code right now ;)
El_Choni
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Good luck with the move! :-)
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Has this lib now been updated? where can i get the latest version?
--Kale

Image
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Not that I've heard.. If you find out please let me know!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Post Reply