Re: puzzling JSON bug

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: puzzling JSON bug
Date: 2013-04-04 19:39:23
Message-ID: 9384.1365104363@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> David Wheeler has presented me with a nasty bug case.
> If I do this:

> select '{"members": { "add": [3, 4]}}'::json #> '{members,add}';

> then I get a crash.

> If I comment out the pfree() at json.c:parse_object_field() lines 378-9
> then I get back the right result but instead get a warning like this:

> WARNING: problem in alloc set ExprContext: bogus aset link in block
> 0x1efaa80, chunk 0x1efb1f0

> I'm not quite sure where I should go looking for what I've done wrong here.

Routine array-overrun memory stomp. The chunk header data for "fname"'s
alloc chunk is being overwritten here:

Watchpoint 2: *(int *) 1075253088

Old value = 1074925616
New value = -1
0x50fe14 in get_array_start (state=0x40170e88) at jsonfuncs.c:688
688 _state->array_level_index[lex_level] = -1;

It appears that lex_level is 2 but only enough room for 2 entries has
been allocated in array_level_index[].

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2013-04-04 19:47:09 Re: puzzling JSON bug
Previous Message Stephen Frost 2013-04-04 19:32:23 Re: Hash Join cost estimates