After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 546339 - multithread crash, SELECT statement to get last inserted row did not return any row
multithread crash, SELECT statement to get last inserted row did not return a...
Status: RESOLVED FIXED
Product: libgda
Classification: Other
Component: SQLite provider
3.99.x
Other All
: Normal critical
: ---
Assigned To: malerba
gnome-db Maintainers
Depends on:
Blocks: 358479
 
 
Reported: 2008-08-04 23:30 UTC by Massimo Cora'
Modified: 2008-10-26 09:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case (7.33 KB, text/plain)
2008-08-30 16:46 UTC, Massimo Cora'
Details
Big memleak with rev #3244. (7.09 KB, text/x-csrc)
2008-10-25 16:17 UTC, Massimo Cora'
Details

Description Massimo Cora' 2008-08-04 23:30:48 UTC
Steps to reproduce:
1. 
2. 
3. 


Stack trace:
first in my population engine I get:

** (anjuta:9242): WARNING **: SELECT statement to get last inserted row did not return any row

** (anjuta:9242): CRITICAL **: gda_set_get_holder_value: assertion `GDA_IS_SET (set)' failed

(anjuta:9242): GLib-GObject-CRITICAL **: g_value_get_int: assertion `G_VALUE_HOLDS_INT (value)' failed


after few seconds a crash appears:
**
** ERROR:(gda-sqlite-recordset.c:204):gda_sqlite_recordset_new: assertion failed: (! ps->stmt_used)

Program received signal SIGABRT, Aborted.

Thread 2983844752 (LWP 11102)

  • #0 raise
    from /lib/libc.so.6
  • #1 abort
    from /lib/libc.so.6
  • #2 g_assertion_message
    from /usr//lib/libglib-2.0.so.0
  • #3 ??
  • #4 ??
  • #0 raise
    from /lib/libc.so.6
  • #1 abort
    from /lib/libc.so.6
  • #2 g_assertion_message
    from /usr//lib/libglib-2.0.so.0
  • #3 ??
  • #4 ??


Other information:
maybe this bug is related to the lack of the implementation of GdaLockable interface in some objects. I'm using GdaSet, GdaDataModel, GdaHolder. 
I'm reporting it here the same, my apologies if I'm wrong.
Comment 1 malerba 2008-08-26 09:54:12 UTC
Could you provide a small example (outside of Anjuta) to make it easy to reprocude the problem?
Comment 2 Massimo Cora' 2008-08-27 20:59:39 UTC
this is not happening if I put a mutex on the engines that avoids concurrent statements executions each on a different gda connection.

It's happening instead if I let libgda's mutexes to protect the execs.

I'm trying to reproduce it outside Anjuta but still no luck...
Comment 3 Massimo Cora' 2008-08-27 21:05:00 UTC
running with --g-fatal-warnings doesn't help:


** Message: sdb_engine_populate_db_by_tags ()
[New Thread 0xb57bdb90 (LWP 9168)]
** Message: generating new statement.. 14
** Message: generating new statement.. 23

** WARNING **: SELECT statement to get last inserted row did not return any row
aborting...

Program received signal SIGABRT, Aborted.

Thread 3020716944 (LWP 9165)

  • #0 raise
    from /lib/libc.so.6
  • #1 abort
    from /lib/libc.so.6
  • #2 g_logv
    from /usr//lib/libglib-2.0.so.0
  • #3 ??


the point in which this error occurs is random.

Comment 4 Massimo Cora' 2008-08-29 17:41:31 UTC
I don't know if can be useful, but I also get a crash with the following stack:

** Message: sdb_engine_populate_db_by_tags ()
Implementation missing: gda_sqlite_provider_statement_execute() in gda-sqlite-provider.c line 2107
[New Thread 0xb2dffb90 (LWP 18802)]
[New Thread 0xb1dffb90 (LWP 18803)]
[Thread 0xb2dffb90 (LWP 18802) exited]
** Message: sdb_engine_populate_db_by_tags ()
**
** ERROR:(gda-sqlite-recordset.c:205):gda_sqlite_recordset_new: assertion failed: (! ps->stmt_used)

Program received signal SIGABRT, Aborted.

Thread 3019889552 (LWP 18799)

  • #0 raise
    from /lib/libc.so.6
  • #1 abort
    from /lib/libc.so.6
  • #2 g_assertion_message
    from /usr//lib/libglib-2.0.so.0
  • #3 ??
  • #4 ??

Comment 5 Massimo Cora' 2008-08-30 16:46:32 UTC
Created attachment 117649 [details]
test case

ok, I'm getting something strange running this example.
I get these messages at some random point:

elapsed 0.360424 av 0.334876
** Message: thread completed cycle
** Message: thread completed cycle

** (process:5443): CRITICAL **: gda_connection_event_get_event_type: assertion `GDA_IS_CONNECTION_EVENT (event)' failed
elapsed 0.421882 av 0.336458
** Message: thread completed cycle


What does the program?
Basically it opens two connections to two different dbs, though only cnc2 is used now.
Then it creates some threads and a 'main_thread' function that insist on that cnc2.
I'm getting only a critical warning, but I think that I can get something more.
btw: probably I'm missing some correct implementation? Please let me know if that's the case.
Comment 6 Massimo Cora' 2008-08-30 17:32:36 UTC
(In reply to comment #5)


got a crash trace:

elapsed 0.315662 av 0.384091
elapsed 0.302091 av 0.383390
elapsed 0.306286 av 0.382737
elapsed 0.280266 av 0.381876

Program received signal SIGSEGV, Segmentation fault.

Thread 3050474384 (LWP 9274)

  • #0 g_type_check_instance_is_a
    from /usr/lib/libgobject-2.0.so.0
  • #1 ??
    from /usr/lib/libgthread-2.0.so.0
  • #2 __pthread_mutex_unlock_usercnt
    from /lib/libpthread.so.0
  • #3 gda_connection_internal_statement_executed
    at gda-connection.c line 3573
  • #4 gda_sqlite_provider_statement_execute
    at gda-sqlite-provider.c line 2156
  • #5 gda_connection_statement_execute_v
    at gda-connection.c line 1486
  • #6 gda_connection_statement_execute_non_select
    at gda-connection.c line 1594
  • #7 thread_statement
    at example.c line 92
  • #8 ??
    from /usr/lib/libglib-2.0.so.0
  • #9 ??
  • #10 ??
  • #11 ??

Comment 7 malerba 2008-09-01 19:12:32 UTC
Can you check with revision 3199? I've added some locking when executing a statement (I wonder why I had not done this earlier...)
Comment 8 Massimo Cora' 2008-09-01 20:09:57 UTC
(In reply to comment #7)
> Can you check with revision 3199? I've added some locking when executing a
> statement (I wonder why I had not done this earlier...)
> 

well, the crash does not appear anymore, nor into the example program nor in Anjuta.

But I found some drawbacks:

* on example_threaded: some little memory is still leaked. You can let run only the thread function, excluding the execute_statement (): you'll see a little but constant increase of memory taken by `example` process. Here it reaches 6 MB at the end of all the threads.
If you want to see it better just increase the number of threads.


* on Anjuta the scanning of files and symbols is very very quick. The drawback is that with this new method [and excluding my mutex on the engine] it only scans 104 symbols. They should be 708 or so.
BTW: this can be easily my fault, since the engine mutex-free hasn't been tested so much. If you say that this kind of bug cannot be of libgda, I'll have a deeper check on my module.

thanks,
Massimo


Comment 9 Massimo Cora' 2008-09-06 13:13:30 UTC
(In reply to comment #8)
> * on Anjuta the scanning of files and symbols is very very quick. The drawback
> is that with this new method [and excluding my mutex on the engine] it only
> scans 104 symbols. They should be 708 or so.
> BTW: this can be easily my fault, since the engine mutex-free hasn't been
> tested so much. If you say that this kind of bug cannot be of libgda, I'll have
> a deeper check on my module.
> 


ok it seems like it was my fault. A little memleak still remains anyway.
Comment 10 Massimo Cora' 2008-10-25 16:17:19 UTC
Created attachment 121350 [details]
Big memleak with rev #3244.

With libgda revision 3244 I notice big memleaks running this example. Note that the example is an updated version of initial "test case".
The memleak seems to occur only when 'thread_statement ()' function is called. No problem instead with 'execute_statement ()'.
Comment 11 malerba 2008-10-25 18:49:38 UTC
Can you check with rev #3245 (for me the mem used no remains constant). Thanks for the test case.
Comment 12 Massimo Cora' 2008-10-25 19:08:55 UTC
all ok, works fine here too,

thanks 
Massimo