oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
339 stars 67 forks source link

`Windows fatal exception: access violation` in thick mode #9

Closed CaselIT closed 12 months ago

CaselIT commented 2 years ago
  1. What versions are you using?
platform.platform: Windows-10-10.0.19044-SP0
sys.maxsize > 2**32: True
platform.python_version: 3.10.4
oracledb.__version__: 1.0.0

I'm using oracle 21.3.0.0, with client version (21, 3, 0, 0, 0)

  1. Is it an error or a hang or a crash? A crash of the python interpreter

  2. What error(s) or behavior you are seeing?

Windows fatal exception: access violation

Current thread 0x00001558 (most recent call first):
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\oracledb\connection.py", line 302 in close
  File "C:\Users\my_user\Dev\GitHub\sqlalchemy\lib\sqlalchemy\engine\default.py", line 599 in do_close
  File "C:\Users\my_user\Dev\GitHub\sqlalchemy\lib\sqlalchemy\pool\base.py", line 316 in _close_connection
  File "C:\Users\my_user\Dev\GitHub\sqlalchemy\lib\sqlalchemy\pool\base.py", line 812 in __close
  File "C:\Users\my_user\Dev\GitHub\sqlalchemy\lib\sqlalchemy\pool\base.py", line 745 in invalidate
  File "C:\Users\my_user\Dev\GitHub\sqlalchemy\lib\sqlalchemy\pool\base.py", line 1343 in invalidate
  File "C:\Users\my_user\Dev\GitHub\sqlalchemy\lib\sqlalchemy\engine\base.py", line 633 in invalidate
  File "C:\Users\my_user\Dev\GitHub\sqlalchemy\test\engine\test_reconnect.py", line 1112 in test_rollback_on_invalid_twophase
  File "C:\Users\my_user\Dev\GitHub\sqlalchemy\lib\sqlalchemy\testing\exclusions.py", line 121 in _do
  File "C:\Users\my_user\Dev\GitHub\sqlalchemy\lib\sqlalchemy\testing\exclusions.py", line 93 in decorate
  File "<string>", line 2 in test_rollback_on_invalid_twophase
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\python.py", line 192 in pytest_pyfunc_call
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_callers.py", line 39 in _multicall
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_manager.py", line 80 in _hookexec
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_hooks.py", line 265 in __call__
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\python.py", line 1761 in runtest
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\runner.py", line 166 in pytest_runtest_call
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_callers.py", line 39 in _multicall
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_manager.py", line 80 in _hookexec
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_hooks.py", line 265 in __call__
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\runner.py", line 259 in <lambda>
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\runner.py", line 338 in from_call
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\runner.py", line 258 in call_runtest_hook
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\runner.py", line 219 in call_and_report
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\runner.py", line 130 in runtestprotocol
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\runner.py", line 111 in pytest_runtest_protocol
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_callers.py", line 39 in _multicall
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_manager.py", line 80 in _hookexec
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_hooks.py", line 265 in __call__
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\main.py", line 347 in pytest_runtestloop
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_callers.py", line 39 in _multicall
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_manager.py", line 80 in _hookexec
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_hooks.py", line 265 in __call__
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\main.py", line 322 in _main
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\main.py", line 268 in wrap_session
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\main.py", line 315 in pytest_cmdline_main
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_callers.py", line 39 in _multicall
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_manager.py", line 80 in _hookexec
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\pluggy\_hooks.py", line 265 in __call__
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\config\__init__.py", line 164 in main
  File "C:\Users\my_user\miniconda3\envs\sa\lib\site-packages\_pytest\config\__init__.py", line 187 in console_main
  File "C:\Users\my_user\miniconda3\envs\sa\Scripts\pytest.exe\__main__.py", line 7 in <module>
  File "C:\Users\my_user\miniconda3\envs\sa\lib\runpy.py", line 86 in _run_code
  File "C:\Users\my_user\miniconda3\envs\sa\lib\runpy.py", line 196 in _run_module_as_main
Windows fatal exception: code 0xebadebad
  1. Does your application call init_oracle_client()?

yes

  1. Include a runnable Python script that shows the problem.

Sadly I cannot reproduce it. I've tried multiple times re-running the same command but it does not reproduce. The crash happened while implementing support for the oracledb driver in sqlalchemy, running pytest --dburi oracle+oracledb://scott:tiger@127.0.0.1:1521/?service_name=XEPDB1 .\test\engine\ and momentarily enabling the thick mode.

The interpreter crashed while executing this test: test/engine/test_reconnect.py::RealReconnectTest_oracle+oracledb_21_3_0_0_0::test_rollback_on_invalid_twophase https://github.com/sqlalchemy/sqlalchemy/blob/ad86d32f7fbd1c6deda8ff3bebe0595c0f2986cc/test/engine/test_reconnect.py#L1108-L1112

I know it's not much to work on, but it's all I have. I've reported since from the stack trace it seems to be a double free or similar since it happened in the close method, so maybe something useful can be gathered from it event with this few information.

Let me know if I can be of further help

cjbj commented 2 years ago

Thanks for logging it; we will do some code reviews etc and see if we can identify what's going on.

CaselIT commented 2 years ago

Ok, a colleague of mine had an unrelated crash of python and mentioned that windows logs an event if an application crashes. I've checked on the machine where I encountered this crash and sure enough there's a log in there, reported below.

seems that KERNELBASE.dll module crashed. Not sure if it can be of any help.

Faulting application name: python.exe, version: 3.10.4150.1013, time stamp: 0x62445d6c
Faulting module name: KERNELBASE.dll, version: 10.0.19041.1706, time stamp: 0x458acb5b
Exception code: 0xc0000005
Fault offset: 0x0000000000034fd9
Faulting process id: 0x61ec
Faulting application start time: 0x01d877760a6b901c
Faulting application path: C:\Users\my_user\miniconda3\envs\sa\python.exe
Faulting module path: C:\Windows\System32\KERNELBASE.dll
Report Id: 21a4f758-4c54-45e1-b886-deeb98f11563
Faulting package full name: 
Faulting package-relative application ID: 

just fyi I've never reproduced it again (but I've not used oracledb much after adding support for it in sqlalchemy)

anthony-tuininga commented 12 months ago

I believe this issue was resolved in the 1.4.2 release. We had another report that was not intermittent and were able to get to the bottom of it, thankfully!

CaselIT commented 12 months ago

Thanks for following up. Glad you had a reproducible report