Re: pgsql: Generational memory allocator

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: pgsql: Generational memory allocator
Дата
Msg-id 6189.1511587105@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: pgsql: Generational memory allocator  (Tomas Vondra <tv@fuzzy.cz>)
Ответы Re: pgsql: Generational memory allocator
Список 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 по дате отправления:

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: pgsql: Generational memory allocator
Следующее
От: Robert Haas
Дата:
Сообщение: pgsql: Avoid projecting tuples unnecessarily in Gather and GatherMerge