Prevent stack overflow in exprLocation while parsing long queries
Thread notes
1 note#bug
hackorum-bot#bug
@global #bug
Hello
In a thread about repack [1]/messages/by-id/awVFP-EHuqyMYv51@alvherre.pgsql Alvaro pointed out that the parser
support for psql is a hack, and since I was already interested in
making the parser available as a library for different projects I
decided to take a look into that.
Shortly after starting, Claude pointed out a trivial bug where a long
chain can cause a stack overflow crash during error reporting.
Since this requires a 1 line fix, I attached a patch for it.
I'm not sure if we want to add a test case for something like this,
but since it doesn't take much time to run or isn't too complex, the
patch includes one.
On 24/11/2026 19:36, Zsolt Parragi wrote:
Hello
In a thread about repack [1] Alvaro pointed out that the parser
support for psql is a hack, and since I was already interested in
making the parser available as a library for different projects I
decided to take a look into that.Shortly after starting, Claude pointed out a trivial bug where a long
chain can cause a stack overflow crash during error reporting.Since this requires a 1 line fix, I attached a patch for it.
I'm not sure if we want to add a test case for something like this,
but since it doesn't take much time to run or isn't too complex, the
patch includes one.
Applied, thanks. I didn't commit the test, it'd be excessive to include
a test for every possible recursion in the system. But thanks for
including it anyway, it was useful for reviewing.
- Heikki