hdbc / hdbc-odbc

ODBC driver for HDBC
BSD 3-Clause "New" or "Revised" License
26 stars 34 forks source link

Fix segmentation fault when GC finalizes statement handle during statement execution on same connection #37

Closed ennocramer closed 5 years ago

ennocramer commented 5 years ago

At least with the Amazon Redshift ODBC driver, it seems that SQLFreeHandle, SQLCloseCursor, or SQLCancel must not be called concurrently with executing a query on another statement handle.

This pull requests delays the actual de-allocation from Haskells GC to the next call of sqlAllocStmt or freeDbcIfNotAlready, thereby moving the call to the de-allocation functions into the same thread as the 'usual' program execution.

The first commit introduces an abstraction to ensure that column buffers have size reported to the driver. This commit is not strictly necessary, but during debugging I noticed column bind buffers for SQLBIGINT were sized to CInt instead of #{type SQLBIGINT}.

anton-dessiatov commented 5 years ago

Thank you! Will make a release on Hackage shortly!

anton-dessiatov commented 5 years ago

Released as 2.5.1.1