-
Notifications
You must be signed in to change notification settings - Fork 564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pyodbc 5.0.0 core dump on connecting with token to mssql #1289
Comments
The fact that the ODBC trace is almost 1MB is already a sign that something is not right, and inspecting closer, it looks like a major breakage happened in the connection attribute processing code. Have you tried using a pure Python+pyODBC script to reproduce it, just to eliminate possibility it's SQLAlchemy? |
Yes, already tested with this samples: Behavior is the same: segfault on pyodbc 5.0.0, normal working on 4.0.38. |
Hi @karoldob , as an experiment, could I ask you to try using a bytearray rather than bytes for the access token in your call to pyodbc.connect. That is, instead of:
try:
It might work. (But of course bytes should work too.) Many thanks. |
Just reporting in here, not sure if there is any relationship, but we have noticed, using Pyodbc 5.0.0, this morning we are no longer able to connect to Azure SQL database. This stopped working over night. We are also using token authentication (to Azure) using the msal library. Getting 100% certain right user and password (clientId & secret) are used and neither are expired. EDIT: downgrading to @ Pyodbc team, can you please look into this? |
@keitherskine |
Changing to Python: 3.9.5 |
Hi. We're seeing the same issue, manifesting when our Great Expectations checkpoint is run. (We have an Azure SQL database configured as a store, which GE connects to using a token.) For us, the error message is:
The pyodbc.connect command is buried within GE, so the suggested |
Hi @karoldob , please do keep this issue open. This looks like a genuine bug. |
I compiled with address sanitization. There is a use after free bug: 0x625000059b61 is located 0 bytes to the right of 8801-byte region [0x625000057900,0x625000059b61) previously allocated by thread T0 here: |
4.0.39 has the same issue, but get's lucky to not hit the bug I think. |
Is the token being freed before it gets used in the connect? |
I compiled a sanitized version of unixodbc 2.3.9 and got this additional information: 0x62500003e361 is located 0 bytes to the right of 8801-byte region [0x62500003c100,0x62500003e361) previously allocated by thread T0 here: |
What parameters are you seeing in your SQLSetConnectAttrW call for the access token? Looks like it's somehow going through the string conversion path, which shouldn't be reached by this code path. Also, is that with or without the proposed fix at #1290 ? |
@v-chojas ugh, I had a bug i my test harness causing it to go down the string path. The PR does indeed fix the issue! |
The pull request keitherskine, 1290, fixes this it sounds like. I'm releasing 5.0.1 with this fix now. Please reopen if I missed something. Thanks everyone for troubleshooting this. |
Environment
Issue
Trying to connect with token as described in:
https://docs.sqlalchemy.org/en/20/dialects/mssql.html#connecting-to-databases-with-access-tokens
How to reproduce:
az login
on your machine (in MS way)engine.connect()
at the endObservations:
pyodbc 4.0.38 is not affected - above samples works well
Just
pip install --upgrade pyodbc==4.0.38
solves the issue, in the same environmentLogin with user-password works well
Trace in attachment
odbctrace.log
The text was updated successfully, but these errors were encountered: