pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Craig Ringer <craig@2ndquadrant.com>
To: pgsql-odbc@postgresql.org <pgsql-odbc@postgresql.org>
Subject: PATCH: Fix minor unallocated memory access in msdtc_enlist.cpp
Date: Mon, 16 Jun 2014 21:27:07 +0800
Message-ID: <539EF0AB.8040408@2ndquadrant.com> (raw )
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>
The attached fixes a minor memory error in msdtc_enlist.cpp, see patch
notes for explanation.
It's in https://github.com/ringerc/psqlODBC.git in the topic branch
return-deleted-memory-fix
Unfortunately, it's not the bug I've been chasing.
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
0001-Fix-access-to-unallocated-memory-in-IAsyncPG.patch (text/x-patch, 2.4K) download
From db413945da7ef668b86811c0df507cb6931090a1 Mon Sep 17 00:00:00 2001
From: Craig Ringer <craig@2ndquadrant.com>
Date: Mon, 16 Jun 2014 21:16:31 +0800
Subject: [PATCH] Fix access to unallocated memory in IAsyncPG
IAsyncPG was deleting its self, then returning an instance variable
by value. This is probably going to be safe pretty much all the time,
but it's still a memory error, and DrMemory (a Windows valgrind-alike)
complains about it:
Error #4: UNADDRESSABLE ACCESS: reading 0x00b1b2b0-0x00b1b2b4 4 byte(s)
# 0 pgenlista.dll!IAsyncPG::Release [c:\users\administrator\desktop\psqlodbc\msdtc_enlist.cpp:352]
# 1 pgenlista.dll!CloseCommitThread [c:\users\administrator\desktop\psqlodbc\msdtc_enlist.cpp:971]
# 2 MSVCR120D.dll!_callthreadstart [f:\dd\vctools\crt\crtw32\startup\thread.c:255]
# 3 MSVCR120D.dll!_threadstart [f:\dd\vctools\crt\crtw32\startup\thread.c:237]
# 4 KERNEL32.dll!BaseThreadInitThunk +0x11 (0x7768338a <KERNEL32.dll+0x1338a>)
Note: @0:00:57.879 in thread 4516
Note: next higher malloc: 0x00b1b420-0x00b1b440
Note: 0x00b1b2b0-0x00b1b2b4 overlaps memory 0x00b1b2a0-0x00b1b390 that was freed here:
Note: # 0 replace_operator_delete [d:\drmemory_package\common\alloc_replace.c:2524]
Note: # 1 pgenlista.dll!IAsyncPG::`scalar deleting destructor'
Note: # 2 pgenlista.dll!IAsyncPG::Release [c:\users\administrator\desktop\psqlodbc\msdtc_enlist.cpp:341]
Note: # 3 pgenlista.dll!CloseCommitThread [c:\users\administrator\desktop\psqlodbc\msdtc_enlist.cpp:971]
Note: # 4 MSVCR120D.dll!_callthreadstart [f:\dd\vctools\crt\crtw32\startup\thread.c:255]
Note: # 5 MSVCR120D.dll!_threadstart [f:\dd\vctools\crt\crtw32\startup\thread.c:237]
Note: # 6 KERNEL32.dll!BaseThreadInitThunk +0x11 (0x7768338a <KERNEL32.dll+0x1338a>)
Note: instruction: mov 0x10(%eax) -> %eax
This patch fixes the issue.
---
msdtc_enlist.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/msdtc_enlist.cpp b/msdtc_enlist.cpp
index ff40761..4795c75 100755
--- a/msdtc_enlist.cpp
+++ b/msdtc_enlist.cpp
@@ -337,8 +337,10 @@ ULONG STDMETHODCALLTYPE IAsyncPG::Release(void)
SLOCK_ACQUIRE();
if (refcnt <=0)
{
+ const int refcnt_copy = refcnt;
mylog("delete %p\n", this);
delete this;
+ return refcnt_copy;
}
else
{
--
1.9.0
Message-ID: <539EF0AB.8040408@2ndquadrant.com>
Permalink: ../539EF0AB.8040408@2ndquadrant.com/
Also on: postgresql.org/message-id/539EF0AB.8040408@2ndquadrant.com
copy link · copy postgr.es · copy git am
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: craig@2ndquadrant.com
Subject: Re: PATCH: Fix minor unallocated memory access in msdtc_enlist.cpp
In-Reply-To: <539EF0AB.8040408@2ndquadrant.com>
References: <539EF0AB.8040408@2ndquadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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