Menu

#41 Invalid handler on 64 bit platform in multithreaded applications

None
open
5
2018-04-26
2017-11-27
No

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).

Discussion

  • Nick Gorham

    Nick Gorham - 2018-04-26
    • assigned_to: Nick Gorham
    • Group: -->
     
  • Nick Gorham

    Nick Gorham - 2018-04-26

    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.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.