Re: Reasons not to like asprintf - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Reasons not to like asprintf
Date
Msg-id 5326.1382474182@sss.pgh.pa.us
Whole thread Raw
In response to Re: Reasons not to like asprintf  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Tom Lane wrote:
>> ... BTW, another reason to choose identical APIs for frontend and backend
>> versions of these functions is that it greatly eases use of them in shared
>> frontend/backend code.  As I notice somebody has *already done* in
>> common/relpath.c.   I'm not exactly sure how those psprintf calls are
>> working at all in frontend builds.

> There's psprintf in src/common/fe_memutils.c, too, using the backend's
> API, which is why this works.

Ah --- that's why it links, anyway.  As for "works", I suspect that the
answer is that anole has a vsnprintf that returns -1 on buffer overrun.
vasprintf and then psprintf will interpret that as "out of memory",
resulting in the observed behavior.  It'd be interesting to see the stack
trace from that error, though, just to confirm this theory.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Failure while inserting parent tuple to B-tree is not fun
Next
From: Tom Lane
Date:
Subject: Re: Failure while inserting parent tuple to B-tree is not fun