wvelandia / spatialite-android

Automatically exported from code.google.com/p/spatialite-android
0 stars 0 forks source link

Statement executed in background thread (e.g. AsyncTask) crashes if GC runs during execution of a user-defined function. #20

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
1. Create a user-defined function and attach it to a jsqlite DB. 
2. Create a thread, perhaps via an AsyncTask (though the crash is repeatable 
inside a regular Thread).
3. Inside the thread, execute your UDF.

Observed:

4. A spectacular crash occurs, taking down the thread from step 2.

Expected:

4. The UDF is executed successfully.

Note that executing the UDF on the main (UI) thread does *not* cause the crash. 
In my case, executing the UDF on the main thread is not a viable solution due 
to the large number of records in my database, though any database - even an 
empty one - will repeatably crash with the above steps.

What version of the product are you using? On what operating system?

Verified on Android 2.2 and 2.3 with the latest version of spatialite-android 
as of the timestamp of this ticket. spatialite-android was built on Mac OS X 
10.7.4 and separately on 10.5.8 - both builds resulted in the described 
behaviour. I do not have the NDK version for the earlier OS X build, but the 
NDK version used on 10.7.4 was r6.

Please provide any additional information below.

I have attached a sample app that reliably (for me) reproduces the problem. I 
included the libs/ directory though it may be necessary to replace the contents 
of this with a local build.

Original issue reported on code.google.com by simon.dr...@gmail.com on 17 Sep 2012 at 2:04

Attachments:

GoogleCodeExporter commented 9 years ago
One other detail: the issue is repeatable if the GC runs during the UDF from 
step 1; it is simple enough to cause garbage collection (which is done in the 
sample code) for a repeatable test.

Original comment by simon.dr...@gmail.com on 17 Sep 2012 at 2:05

GoogleCodeExporter commented 9 years ago

Original comment by efroh...@gmail.com on 10 Nov 2012 at 1:33

GoogleCodeExporter commented 9 years ago
Having exactly same issue. db.exec() doesn't work in async task, in my case it 
is ordinary insert statement. 

Original comment by melny...@gmail.com on 23 Nov 2013 at 2:02

GoogleCodeExporter commented 9 years ago
Apologies for my previous comment, actually it worked OK. 
Thanks. 

Original comment by melny...@gmail.com on 23 Nov 2013 at 9:26