From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Dmitry Mityugov <d(dot)mityugov(at)postgrespro(dot)ru>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: patch: Use pg_assume in jsonb_util.c to fix GCC 15 warnings |
Date: | 2025-07-12 19:23:26 |
Message-ID: | 140175.1752348206@sss.pgh.pa.us |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
After further study I've understood what was bothering me about
the logic in compareJsonbContainers (lines 280ff). Because
JsonbIteratorNext doesn't presently guarantee to set val->type
when returning WJB_DONE, the stanza appears to be at risk of
undefined behavior should one iterator return that while the other
returns something else. The comment fails to discuss this case,
and the code doesn't consider it either. But in reality, the case
cannot happen for the exact same reason that WJB_END_ARRAY and
WJB_END_OBJECT can't occur: our earlier tests of object and array
structure & length matching guarantee that we can't reach the end
of one input before the other.
So I think we need to rewrite that comment and extend the assertions,
along the lines of the separate patch attached. This gets through
check-world, which is unsurprising because if it did not we'd have
seen use-of-undefined-value Valgrind complaints long since.
I still think that we should silence the compiler warnings by
removing the undefined-ness per my previous patch. I'm inclined
to back-patch that (for people compiling old branches with latest
compiler) but apply this bit to HEAD only (since it's just a code
clarification).
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
v3-rationalize-compareJsonbContainers.patch | text/x-diff | 1.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Nathan Bossart | 2025-07-12 19:36:05 | Re: XLogCtl->ckptFullXid is unused |
Previous Message | Daniel Gustafsson | 2025-07-12 19:14:44 | Re: Adding support for SSLKEYLOGFILE in the frontend |