Invalid handler on 64 bit platform in multithreaded applications
Brought to you by:
lurcher,
peteralexharvey
When allocating a handler in a thread different then the main thread, the call to functions on that thread will report invalid handle.
As I investigated, the problem lies in the way the handle value is computed, as the value of the pointer to the handle's internal data structure. I added some printf statements in the __handles.c
code and i got the following result:
unixODBC -- __alloc_stmt: statement_root: (nil) unixODBC -- __alloc_stmt: new statement: 0x7fe1c0000c50 unixODBC -- __validate_stmt: statement_root: 0x7fe1c0000c50 unixODBC -- __validate_stmt: statement: 0xffffffffc0000c50 unixODBC -- __validate_stmt: 0x7fe1c0000c50 != 0xffffffffc0000c50 unixODBC -- __validate_stmt returning: 0
You can see that, when __validate_stmt
is called with the statement handle's value, the value is truncated to 32 bit (ODBC SQLINTEGER is 32 bit long).
Only just seen this. AFAIK, a handle is a void ptr so shoudn't be truncated. Do you have some code that shows the problem.
Sorry its taken so long, I iad not seen the bug report.