classification
Title: Bug in 3rd party sybase database connector (Fatal python error:PyEval_RestoreThread NULL tstate)
Type: crash Stage: resolved
Components: Tests Versions: Python 3.7
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: amitrutvij, vstinner
Priority: normal Keywords:

Created on 2020-03-25 16:57 by amitrutvij, last changed 2020-03-26 00:17 by vstinner. This issue is now closed.

Messages (5)
msg365001 - (view) Author: Amit Moghe (amitrutvij) Date: 2020-03-25 16:57
Hi Team, I am writting an application in python flask. I  this when flask application is establishing Sybase DB connection through normal python SybaseConnector. In this process I am getting below error, could you please suggest on this ?
Error :Fatal python error:PyEval_RestoreThread NULL tstate
flask/1.0.2/lib/flask/app.py line 1815 in full_dispatch_request
Memory fault(Coredump)

Could you please suggest on this?
msg365002 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-25 17:01
This issue looks like a bug in Flask or a C extension used by your application. You should try to debug it with gdb. Or at least try to get a Python traceback:
https://pythondev.readthedocs.io/debug_tools.html#get-a-traceback-on-a-crash

You should specify your Python version, OS and OS version, explain how to reproduce the crash, etc.
msg365003 - (view) Author: Amit Moghe (amitrutvij) Date: 2020-03-25 17:16
Hi ,

Please see below trace logger -
 
Failed transaction.
Statement: SELECT Col1, Col2, Col3 FROM TABLE where APPLICATION='TEST'  ORDER BY UPDATE_TIME DESCFatal Python error: PyEval_RestoreThread: NULL tstate


Current thread 0x00007f3e435fe700 (most recent call first):
  File "/generic_sybase_connector.py", line 175 in _do
  File "/generic_sybase_connector.py", line 155 in _safe_cursor_operation
  File "/generic_sybase_connector.py", line 184 in fetch_from_db
  File "/cva_sybase_connector.py", line 197 in get_smoke_test_name_data
  File "/db_connector.py", line 197 in get
  File "/dist/python/PROJ/flask-restful/0.3.6/lib/flask_restful/__init__.py", line 595 in dispatch_request
  File "/dist/python/PROJ/flask/1.0.2/lib/flask/views.py", line 88 in view
  File "/dist/python/PROJ/flask-restful/0.3.6/lib/flask_restful/__init__.py", line 480 in wrapper
  File "/dist/python/PROJ/flask/1.0.2/lib/flask/app.py", line 1799 in dispatch_request
  File "/dist/python/PROJ/flask/1.0.2/lib/flask/app.py", line 1813 in full_dispatch_request
  File "/dist/python/PROJ/flask/1.0.2/lib/flask/app.py", line 2292 in wsgi_app
  File "/dist/python/PROJ/flask/1.0.2/lib/flask/app.py", line 2309 in __call__
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/debug/__init__.py", line 288 in debug_application
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/serving.py", line 260 in execute
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/serving.py", line 270 in run_wsgi
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/serving.py", line 328 in handle_one_request
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/http/server.py", line 401 in handle
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/serving.py", line 293 in handle
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/socketserver.py", line 673 in __init__
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/socketserver.py", line 344 in finish_request
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/socketserver.py", line 617 in process_request_thread
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/threading.py", line 859 in run
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/threading.py", line 911 in _bootstrap_inner
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/threading.py", line 879 in _bootstrap

Thread 0x00007f3e4924d700 (most recent call first):
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/tokenize.py", line 454 in open
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/linecache.py", line 130 in updatecache
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/linecache.py", line 42 in getlines
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/linecache.py", line 15 in getline
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/traceback.py", line 65 in _extract_tb_or_stack_iter
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/traceback.py", line 18 in _format_list_iter
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/traceback.py", line 153 in _format_exception_iter
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/traceback.py", line 181 in format_exception
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/traceback.py", line 256 in format_exc
  File "/generic_sybase_connector.py", line 159 in _safe_cursor_operation
  File "/generic_sybase_connector.py", line 184 in fetch_from_db
  File "/cva_sybase_connector.py", line 128 in get_dashboard_data
  File "/db_connector.py", line 50 in get
  File "/dist/python/PROJ/flask-restful/0.3.6/lib/flask_restful/__init__.py", line 595 in dispatch_request
  File "/dist/python/PROJ/flask/1.0.2/lib/flask/views.py", line 88 in view
  File "/dist/python/PROJ/flask-restful/0.3.6/lib/flask_restful/__init__.py", line 480 in wrapper
  File "/dist/python/PROJ/flask/1.0.2/lib/flask/app.py", line 1799 in dispatch_request
  File "/dist/python/PROJ/flask/1.0.2/lib/flask/app.py", line 1813 in full_dispatch_request
  File "/dist/python/PROJ/flask/1.0.2/lib/flask/app.py", line 2292 in wsgi_app
  File "/dist/python/PROJ/flask/1.0.2/lib/flask/app.py", line 2309 in __call__
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/debug/__init__.py", line 288 in debug_application
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/serving.py", line 260 in execute
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/serving.py", line 270 in run_wsgi
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/serving.py", line 328 in handle_one_request
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/http/server.py", line 401 in handle
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/serving.py", line 293 in handle
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/socketserver.py", line 673 in __init__
  File "/dist/pythTraceback (most recent call last):
  File "/generic_sybase_connector.py", line 155, in _safe_cursor_operation
    return fct(cursor)
  File "/generic_sybase_connector.py", line 175, in _do
    cursor.execute(query, params)
sybpydb.InternalError: ('Error in creating new statement: DBCAPI layer: Error: CT-Lib routine ct_cmd_alloc failed.', 134283521)
on/PR
OJ/core/3.4.4/exec/lib/python3.4/socketserver.py", line 344 in finish_request
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/socketserver.py", line 617 in process_request_thread
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/threading.py", line 859 in run
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/threading.py", line 911 in _bootstrap_inner
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/threading.py", line 879 in _bootstrap

Thread 0x00007f3e5cb02700 (most recent call first):
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/socketserver.py", line 154 in _eintr_retry
  File "/dist/python/PROJ/core/3.4.4/exec/lib/python3.4/socketserver.py", line 236 in serve_forever
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/serving.py", line 612 in serve_forever
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/serving.py", line 777 in inner
  File "/dist/python/PROJ/werkzeug/0.14.1/lib/werkzeug/serving.py", line 814 in run_simple
  File "/dist/python/PROJ/flask/1.0.2/lib/flask/app.py", line 943 in run
  File "webapp.py", line 148 in <module>
Memory fault(coredump)
msg365004 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-25 17:18
File "/generic_sybase_connector.py", line 175 in _do
  File "/generic_sybase_connector.py", line 155 in _safe_cursor_operation
  File "/generic_sybase_connector.py", line 184 in fetch_from_db
  File "/cva_sybase_connector.py", line 197 in get_smoke_test_name_data
  File "/db_connector.py", line 197 in get
  File "/dist/python/PROJ/flask-restful/0.3.6/lib/flask_restful/__init__.py", line 595 in dispatch_request

It looks likle a bug in your sybase database connector.
msg365034 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-26 00:17
I close the issue. It's a bug in a third-party project, not in Python itself.

If you can reproduce the bug with a simple script which only uses the stdlib, please reopen the issue.
History
Date User Action Args
2020-03-26 00:17:42vstinnersetstatus: open -> closed
title: Fatal python error:PyEval_RestoreThread NULL tstate -> Bug in 3rd party sybase database connector (Fatal python error:PyEval_RestoreThread NULL tstate)
messages: + msg365034

resolution: third party
stage: resolved
2020-03-25 17:18:19vstinnersetmessages: + msg365004
2020-03-25 17:16:41amitrutvijsetmessages: + msg365003
2020-03-25 17:01:33vstinnersetnosy: + vstinner
messages: + msg365002
2020-03-25 16:57:23amitrutvijcreate