Closed pedeeme closed 1 year ago
I tried to reproduce it but got a different error, "A TVP's rows must all be the same size.", it seems to think that a row being passed in is 11 columns instead of 14 for some reason.
I'm afraid I won't be able to look deeper into it until the new year, though.
Hello,
Tried running the code I actually posted and was able to reproduce again, this was my output with the flag set to not crash:
Testing pyodbc on calling procedures with TVP arguments
os: Linux
Current directory: /mnt/c/temp/pyodbc_crash
sys path: ['/mnt/c/temp/pyodbc_crash', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/pedro/.local/lib/python3.8/site-packages', '/usr/local/lib/python3.8/dist-packages', '/usr/local/lib/python3.8/dist-packages/pyodbc-4.0.33b6-py3.8-linux-x86_64.egg', '/usr/lib/python3/dist-packages']
python: 3.8.10 (default, Sep 28 2021, 16:10:42)
[GCC 9.3.0]
pyodbc: 4.0.32 /home/pedro/.local/lib/python3.8/site-packages/pyodbc.cpython-38-x86_64-linux-gnu.so
----START ----
Getting line 0
Exec data-set:0 with 1 lines
res: [(0, '')]
---------------
Getting line 1
Exec data-set:1 with 1 lines
res: [(0, '')]
---------------
Getting line 2
Exec data-set:2 with 1 lines
res: [(0, '')]
---------------
Getting line 3
Exec data-set:3 with 1 lines
res: [(0, '')]
---------------
Getting line 4
Exec data-set:4 with 1 lines
res: [(0, '')]
---------------
Getting line 5
Exec data-set:5 with 1 lines
res: [(0, '')]
---------------
Getting line 6
Exec data-set:6 with 1 lines
res: [(0, '')]
---------------
Getting line 7
Exec data-set:7 with 1 lines
res: [(0, '')]
---------------
Getting line 8
Exec data-set:8 with 1 lines
res: [(0, '')]
---------------
Getting line 9
Exec data-set:9 with 1 lines
res: [(0, '')]
---------------
Everything went A-OK and nothing crashed!
And on the database the data was inserted on all 14 columns
the_id field_1 field_2 field_3 field_4 field_5 field_6 field_7 field_8 field_9 field_10 field_11 field_12 field_13
----------- -------------------- ----------- -------------------- ------- -------------------- ----------- ------- --------------------------- ------- ----------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------- --------
39 1001 1 1101 NULL NULL 0 0 2021-01-01 14:50:11.00 0 NULL NULL NULL 1
40 2001 1 2201 NULL NULL 0 0 2021-02-02 14:50:11.00 0 NULL NULL NULL 1
41 3001 1 3301 NULL NULL 0 0 2021-03-03 14:50:11.00 0 NULL NULL NULL 1
42 4001 1 4401 NULL NULL 0 0 2021-04-04 14:50:11.00 0 NULL NULL NULL 1
43 5001 1 5501 NULL NULL 0 0 2021-05-05 14:50:11.00 0 NULL NULL NULL 1
44 6001 1 6601 NULL NULL 0 0 2021-06-06 14:50:11.00 0 NULL NULL NULL 1
45 7001 1 7701 NULL NULL 0 0 2021-07-07 14:50:11.00 0 NULL NULL NULL 1
46 8001 1 8801 NULL NULL 0 0 2021-08-08 14:50:11.00 0 NULL NULL NULL 1
47 9001 1 9901 NULL NULL 0 0 2021-09-09 14:50:11.00 0 NULL NULL NULL 1
48 10001 1 11001 NULL NULL 0 0 2021-10-10 14:50:11.00 0 NULL NULL NULL 1
(10 rows affected)
Completion time: 2021-12-18T00:25:45.4587229+00:00
Settting the flag to crash would also crash python as expected
Hello, I forgot to mention something important this only happens on Linux, running this test on Windows ( in a powershell ) has no issues and does not crashes
Check unixODBC version, older versions (<2.3.5) buggy may cause this.
Hello v-chojas
My unixODBC version is 2.3.7
pedro@PT-PEDMARQU1:/usr/bin$ odbcinst --version
unixODBC 2.3.7
The 2.3.9 was already released but on apt-get 2.3.7 is still listed as the current version.
I'm going to close this for inactivity. If someone could confirm with 2.3.9 it would be useful.
Environment
Also had issue on an alpine docker container with python 3.10 and pyodbc 4.0.32
Issue
Python crashes with segmentation fault when executing a stored procedure with a TVP argument on a non-default table schema, the TVP has 13 arguments and if the last column is not null python does not crashes
Setup database
Run the follow database commands to create the table, table type and stored procedure. It assumes the schema "some_schema" exists:
Code to reproduce problem
Run the following python script. In order to reproduce problem change the variable "do_you_want_to_crash" to True. In order to see a execution without crahes set variable to False. Also set database connection variables on line 11:
Crash information
I tried debugging the problem and the memory corruption shifts whether I use debug messages or gdb. With gdb the crash is on a SQLAllocHandle called in Cursor_New
But adding debug messges to 4.0.33b6 the crash moves to this line :
on the execute function.
I am just starting to use pyodbc so I am not familiar with the code so any help would be appreciated.
Best Regards