In frame 0, the pointer passed to sqlite3_value_type is NULL, which is causing 
the segfault
In frame 1, an unknown column (index is "optimized out") of the current row of 
an SQLite3 Statement is queried

The rest of the stack is Python SQLite Wrapper and Python implementation code. 
Can't help with that, sorry.

Setting a conditional breakpoint on sqlite3_value_type() in the debugger will 
let you trap the error before the segfault happens, so that you can inspect the 
internal state of the SQLite statement.

My guess: The python wrapper is calling sqlite3_column_type() on a statement 
that either
    - has no current row (i.e. the last call to sqlite3_step did not return 
SQLITE_ROW and/or sqlite3_reset() or sqlite3_finalize() have been called), or
    - has no result column with the index passed (i.e. iCol < 0 or iCol > 
sqlite3_column_count())

This could be caused by improper use of threading and shared objects in your 
Python code, you are probably better served if you post your Python code on a 
Python list.

Note that it does not matter which thread calls sqlite3_reset() or 
sqlite3_finalize(), the statement is reset/finalized when any thread calls the 
functions.

-----Urspr√ľngliche Nachricht-----
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von Wang, Peter (Xu)
Gesendet: Freitag, 03. November 2017 02:23
An: sqlite-users@mailinglists.sqlite.org
Cc: wangxu198...@gmail.com
Betreff: [EXTERNAL] [sqlite] deadlock between query and insert in-memory db

Can anyone help me on this?

Thanks
Peter

From: Wang, Peter (Xu)
Sent: Tuesday, October 31, 2017 4:19 PM
To: 'sqlite-users@mailinglists.sqlite.org' 
<sqlite-users@mailinglists.sqlite.org>
Cc: wangxu198...@gmail.com
Subject: Segfault when query again in-memory db

Hi
I am trying to provide a asychnonous queue based on sqlite3 in Python Current, 
I already passted the file based tests with my queue When switching file to 
in-memory db, I keep meeting a "segfault" issue when running the same tests 
test suite

Can anyone help me out of this situation?


I tested the in-memory with multi-thread (but inserts/deletes are in a lock) 
Here is the trace of the core file:

(gdb) bt
#0  sqlite3_value_type (pVal=0x0) at sqlite3.c:72512
#1  0x00007fda2a34fd86 in sqlite3_column_type (pStmt=0x7fda08004178, 
i=<optimized out>) at sqlite3.c:73318
#2  0x00007fda2a607987 in _pysqlite_fetch_one_row 
(self=self@entry=0x7fda2a204b20) at 
/build/python2.7-1tJBSB/python2.7-2.7.12/Modules/_sqlite/cursor.c:352
#3  0x00007fda2a6089c1 in _pysqlite_query_execute (self=0x7fda2a204b20, 
multiple=<optimized out>, args=<optimized out>)
    at /build/python2.7-1tJBSB/python2.7-2.7.12/Modules/_sqlite/cursor.c:711
#4  0x00000000004b0cb3 in PyObject_Call () at ../Objects/abstract.c:2546
#5  0x00000000004ce5d0 in PyEval_CallObjectWithKeywords () at 
../Python/ceval.c:4219
#6  0x00007fda2a609106 in pysqlite_connection_execute (self=<optimized out>, 
args=('SELECT _id, data FROM queue_default ORDER BY _id ASC LIMIT 1', ()))
    at 
/build/python2.7-1tJBSB/python2.7-2.7.12/Modules/_sqlite/connection.c:1262
#7  0x00000000004cb945 in call_function (oparg=<optimized out>, 
pp_stack=0x7fda19ff9fc0) at ../Python/ceval.c:4350
#8  PyEval_EvalFrameEx () at ../Python/ceval.c:2987
#9  0x00000000004c2765 in PyEval_EvalCodeEx () at ../Python/ceval.c:3582
#10 0x00000000004ca8d1 in fast_function (nk=0, na=<optimized out>, n=<optimized 
out>, pp_stack=0x7fda19ffa1d0, func=<function at remote 0x7fda2a83c050>)
    at ../Python/ceval.c:4445
#11 call_function (oparg=<optimized out>, pp_stack=0x7fda19ffa1d0) at 
../Python/ceval.c:4370
#12 PyEval_EvalFrameEx () at ../Python/ceval.c:2987
#13 0x00000000004c9d8f in fast_function (nk=<optimized out>, na=<optimized 
out>, n=<optimized out>, pp_stack=0x7fda19ffa320,
    func=<function at remote 0x7fda2a8416e0>) at ../Python/ceval.c:4435
#14 call_function (oparg=<optimized out>, pp_stack=0x7fda19ffa320) at 
../Python/ceval.c:4370
#15 PyEval_EvalFrameEx () at ../Python/ceval.c:2987
#16 0x00000000004c2765 in PyEval_EvalCodeEx () at ../Python/ceval.c:3582
#17 0x00000000004ca099 in fast_function (nk=1, na=<optimized out>, n=<optimized 
out>, pp_stack=0x7fda19ffa530, func=<function at remote 0x7fda2a841758>)
    at ../Python/ceval.c:4445
#18 call_function (oparg=<optimized out>, pp_stack=0x7fda19ffa530) at 
../Python/ceval.c:4370
#19 PyEval_EvalFrameEx () at ../Python/ceval.c:2987
#20 0x00000000004c2765 in PyEval_EvalCodeEx () at ../Python/ceval.c:3582
#21 0x00000000004de8b8 in function_call.lto_priv () at 
../Objects/funcobject.c:523
#22 0x00000000004b0cb3 in PyObject_Call () at ../Objects/abstract.c:2546
#23 0x00000000004c6ad1 in ext_do_call (nk=<optimized out>, na=<optimized out>, 
flags=<optimized out>, pp_stack=0x7fda19ffa7e8,
    func=<function at remote 0x7fda29fd6c80>) at ../Python/ceval.c:4664
#24 PyEval_EvalFrameEx () at ../Python/ceval.c:3026
#25 0x00000000004c9d8f in fast_function (nk=<optimized out>, na=<optimized 
out>, n=<optimized out>, pp_stack=0x7fda19ffa930,
    func=<function at remote 0x7fda2da20758>) at ../Python/ceval.c:4435
#26 call_function (oparg=<optimized out>, pp_stack=0x7fda19ffa930) at 
../Python/ceval.c:4370
#27 PyEval_EvalFrameEx () at ../Python/ceval.c:2987
#28 0x00000000004c9d8f in fast_function (nk=<optimized out>, na=<optimized 
out>, n=<optimized out>, pp_stack=0x7fda19ffaa80, ---Type <return> to continue, 
or q <return> to quit---
    func=<function at remote 0x7fda2da208c0>) at ../Python/ceval.c:4435
#29 call_function (oparg=<optimized out>, pp_stack=0x7fda19ffaa80) at 
../Python/ceval.c:4370
#30 PyEval_EvalFrameEx () at ../Python/ceval.c:2987
#31 0x00000000004c2765 in PyEval_EvalCodeEx () at ../Python/ceval.c:3582
#32 0x00000000004de6fe in function_call.lto_priv () at 
../Objects/funcobject.c:523
#33 0x00000000004b0cb3 in PyObject_Call () at ../Objects/abstract.c:2546
#34 0x00000000004f492e in instancemethod_call.lto_priv () at 
../Objects/classobject.c:2602
#35 0x00000000004b0cb3 in PyObject_Call () at ../Objects/abstract.c:2546
#36 0x00000000004ce5d0 in PyEval_CallObjectWithKeywords () at 
../Python/ceval.c:4219
#37 0x0000000000597e32 in t_bootstrap () at ../Modules/threadmodule.c:620
#38 0x00007fda2d77f6ba in start_thread (arg=0x7fda19ffb700) at 
pthread_create.c:333
#39 0x00007fda2d4b53dd in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Here is the python trace:

(gdb) py-bt
Traceback (most recent call first):
  File "/home/user/Documents/persist-queue/persistqueue/sqlbase.py", line 140, 
in _select
    def _select(self, *args):
  File "/home/user/Documents/persist-queue/persistqueue/sqlqueue.py", line 49, 
in _pop
    row = self._select()
  File "/home/wangp11/Documents/persist-queue/persistqueue/sqlqueue.py", line 
67, in get
    pickled = self._pop()
  File "/home/user/Documents/persist-queue/tests/test_sqlqueue.py", line 105, 
in consumer
    x = m_queue.get(block=True)
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 774, in __bootstrap
    self.__bootstrap_inner()
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick | Software Engineer | Scientific Games International GmbH | 
Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 
1 80100 - 0

May be privileged. May be confidential. Please delete if not the addressee.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to