pg.ddx.io GitHub: postgresql-interfaces/psqlodbc (issues + PRs as email threads)help / color / mirror / Atom feed
[postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup 11+ messages / 3 participants [nested] [flat]
* [postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup @ 2026-05-21 12:35 "cipriani-ivan (@cipriani-ivan)" <noreply+cipriani-ivan@github.com> 0 siblings, 0 replies; 11+ messages in thread From: cipriani-ivan (@cipriani-ivan) @ 2026-05-21 12:35 UTC (permalink / raw) To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com> Dear psqlODBC maintainers, I would like to report a potential memory corruption issue in the PostgreSQL ODBC driver and ask whether this is a known or tracked problem. Summary We are observing repeatable heap corruption (0xC0000374) in a .NET application using: PostgreSQL: 17.9 psqlODBC: 17.0.0.4 Windows: x64 Driver: PostgreSQL Unicode (x64) The failure occurs during connection teardown after a failed connection. Observed behavior With Application Verifier + Page Heap, the crash consistently reports: HEAP_CORRUPTION_ACTIONABLE_BlockNotBusy_DOUBLE_FREE Stack trace Below is the stack trace captured in WinDbg: ucrtbase!free_base psqlodbc35w!SC_clear_error psqlodbc35w!PGAPI_FreeStmt psqlodbc35w!SQLFreeStmt odbc32!SQLDisconnect System.Data.Odbc.OdbcConnection.Close() This suggests a double free during statement/connection cleanup, likely in an error path. Reproduction scenario The issue appears under the following conditions: Connection attempt fails (e.g. SQLSTATE 08S01, connection down) Application immediately disposes the connection Cleanup invokes SQLDisconnect / SQLFreeStmt Occurs more frequently under: Release builds Parallel workloads Forced cleanup paths Analysis / suspicion Multiple cleanup layers (SC_clear_error, PGAPI_FreeStmt) appear to release overlapping resources The issue occurs in a failure path (connection already down) Recent release notes do not indicate changes in this cleanup logic Similar memory-safety fixes exist historically but not in this code path Questions Is this behavior a known issue in current psqlODBC versions? Is there ongoing work related to cleanup safety in error paths? Are there recommended usage constraints (threading / disposal patterns) to avoid this? Context This occurs in a modern multithreaded .NET application, where: Failed connections are disposed immediately Cleanup may occur under concurrency Robust handling of failure paths is required We understand the complexity of ODBC lifecycle semantics, but this appears to expose a double-free condition under certain cleanup scenarios. Thank you for your time and for maintaining psqlODBC. Best regards, Ivan Cipriani ^ permalink raw [nested|flat] 11+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup @ 2026-05-22 14:55 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 9 siblings, 0 replies; 11+ messages in thread From: davecramer (@davecramer) @ 2026-05-22 14:55 UTC (permalink / raw) To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com> I have a possible solution in #190 Is it possible for you to test without me publishing a release? ^ permalink raw [nested|flat] 11+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup @ 2026-05-26 13:14 ` "cipriani-ivan (@cipriani-ivan)" <noreply+cipriani-ivan@github.com> 9 siblings, 0 replies; 11+ messages in thread From: cipriani-ivan (@cipriani-ivan) @ 2026-05-26 13:14 UTC (permalink / raw) To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com> Thank you for the proposed solution in [#190](https://github.com/postgresql-interfaces/psqlodbc/pull/190). I’ll attempt to test it, though I’m not certain I’ll be able to set it up successfully. Do you have an estimated timeline for the release? ^ permalink raw [nested|flat] 11+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup @ 2026-05-30 16:01 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 9 siblings, 0 replies; 11+ messages in thread From: davecramer (@davecramer) @ 2026-05-30 16:01 UTC (permalink / raw) To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com> @davecramer closed this. ^ permalink raw [nested|flat] 11+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup @ 2026-05-30 16:03 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 9 siblings, 0 replies; 11+ messages in thread From: davecramer (@davecramer) @ 2026-05-30 16:03 UTC (permalink / raw) To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com> No real ETA. Was hoping to release soon though ^ permalink raw [nested|flat] 11+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup @ 2026-06-01 08:39 ` "cipriani-ivan (@cipriani-ivan)" <noreply+cipriani-ivan@github.com> 9 siblings, 0 replies; 11+ messages in thread From: cipriani-ivan (@cipriani-ivan) @ 2026-06-01 08:39 UTC (permalink / raw) To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com> Hi @davecramer, Thank you again for providing the proposed fix in #190. I’ve been able to build and test the driver from the branch. Unfortunately, we are still able to reproduce a crash during the same teardown scenario. The behavior has changed slightly, though: The process still terminates during cleanup after a failed connection Instead of the previous heap corruption signature, we now consistently see: FATAL: terminating connection due to administrator command The crash still occurs in the same general flow (connection failure → immediate disposal → cleanup) In addition, we are observing similar instability in a few other failure scenarios, particularly in situations where a connection is closed and a new one is created shortly after. So while the symptom has changed, it seems the underlying issue is not fully resolved yet. Thanks again for your work on this. Best regards, ^ permalink raw [nested|flat] 11+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup @ 2026-06-03 13:45 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 9 siblings, 0 replies; 11+ messages in thread From: davecramer (@davecramer) @ 2026-06-03 13:45 UTC (permalink / raw) To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com> @cipriani-ivan any way you could provide a reproducer for this ? Or even logs from PostgreSQL ? Are you able to get a stack trace ? ^ permalink raw [nested|flat] 11+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup @ 2026-06-03 13:45 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 9 siblings, 0 replies; 11+ messages in thread From: davecramer (@davecramer) @ 2026-06-03 13:45 UTC (permalink / raw) To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com> @davecramer reopened this. ^ permalink raw [nested|flat] 11+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup @ 2026-07-09 15:48 ` "fesswanderer (@fesswanderer)" <noreply+fesswanderer@github.com> 9 siblings, 0 replies; 11+ messages in thread From: fesswanderer (@fesswanderer) @ 2026-07-09 15:48 UTC (permalink / raw) To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com> Hi @davecramer ! I'm Denis and I'm working on the same project as @cipriani-ivan (he's on vacation now). Just wanted to say thank you for the fix :) Although Ivan experienced some problems testing this fix before release, we suspect that it could probably be related to building process. Now, as this fix is a part of psqlODBC 18.0.2 version release, we could test this again and compare with older version: 17.0.10 - Reproducible reliably. 18.0.2 - Unable to reproduce. Used the same PC and the same steps to reproduce. So as long as the problem with memory allocation is gone, it seems now we can handle our cases gracefully on upper level. Thanks again for fixing this, and have a good summer! :) ^ permalink raw [nested|flat] 11+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup @ 2026-07-10 09:57 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 9 siblings, 0 replies; 11+ messages in thread From: davecramer (@davecramer) @ 2026-07-10 09:57 UTC (permalink / raw) To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com> @davecramer closed this. ^ permalink raw [nested|flat] 11+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup @ 2026-07-10 09:57 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 9 siblings, 0 replies; 11+ messages in thread From: davecramer (@davecramer) @ 2026-07-10 09:57 UTC (permalink / raw) To: postgresql-interfaces/psqlodbc <noreply+postgresql-interfaces-psqlodbc@github.com> @fesswanderer strange, but OK. Let me know if this pops up again. ^ permalink raw [nested|flat] 11+ messages in thread
end of thread, other threads:[~2026-07-10 09:57 UTC | newest] Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-05-21 12:35 [postgresql-interfaces/psqlodbc] issue #189: Possible double-free / heap corruption in psqlODBC during SQLDisconnect cleanup "cipriani-ivan (@cipriani-ivan)" <noreply+cipriani-ivan@github.com> 2026-05-22 14:55 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 2026-05-26 13:14 ` "cipriani-ivan (@cipriani-ivan)" <noreply+cipriani-ivan@github.com> 2026-05-30 16:01 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 2026-05-30 16:03 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 2026-06-01 08:39 ` "cipriani-ivan (@cipriani-ivan)" <noreply+cipriani-ivan@github.com> 2026-06-03 13:45 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 2026-06-03 13:45 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 2026-07-09 15:48 ` "fesswanderer (@fesswanderer)" <noreply+fesswanderer@github.com> 2026-07-10 09:57 ` "davecramer (@davecramer)" <noreply+davecramer@github.com> 2026-07-10 09:57 ` "davecramer (@davecramer)" <noreply+davecramer@github.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox