Re: pgsql: Generational memory allocator - Mailing list pgsql-committers

From Tom Lane
Subject Re: pgsql: Generational memory allocator
Date
Msg-id 6189.1511587105@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgsql: Generational memory allocator  (Tomas Vondra <tv@fuzzy.cz>)
Responses Re: pgsql: Generational memory allocator  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-committers
Tomas Vondra <tv@fuzzy.cz> writes:
> BTW I also see these failures in hstore:

> ==15168== Source and destination overlap in memcpy(0x5d0fed0, 0x5d0fed0, 40)
> ==15168==    at 0x4C2E00C: memcpy@@GLIBC_2.14 (vg_replace_strmem.c:1018)
> ==15168==    by 0x15419A06: hstoreUniquePairs (hstore_io.c:343)
> ==15168==    by 0x15419EE4: hstore_in (hstore_io.c:416)

Huh ...

> Seems hstoreUniquePairs may call memcpy with the same pointers in some 
> cases (which looks a bit dubious). But the code is ancient, so it's 
> strange it didn't fail before.

Quite.  It's easy to see how to avoid the nominally-undefined behavior:

-            memcpy(res, ptr, sizeof(Pairs));
+            if (res != ptr)
+                memcpy(res, ptr, sizeof(Pairs));

but this should surely have been noticed by valgrind tests before.
The case doesn't necessarily occur --- if the first two items in
sorted order are dups, it won't --- but if you're seeing it occur
in regression testing then skink should have seen it as well.
        regards, tom lane


pgsql-committers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: pgsql: Generational memory allocator
Next
From: Robert Haas
Date:
Subject: pgsql: Avoid projecting tuples unnecessarily in Gather and GatherMerge