Re: Ubsan complaint on kestrel

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Ubsan complaint on kestrel
Date: 2025-03-03 21:49:09
Message-ID: 4082535.1741038549@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)de> writes:
> ../../../../../home/andres/src/postgresql/src/backend/nodes/nodeFuncs.c:2712:6: runtime error: call to function assign_query_collations_walker through pointer to incorrect function type 'bool (*)(struct Node *, void *)'
> /srv/dev/build/postgres/m-dev-assert-clang-sanitizer/../../../../../home/andres/src/postgresql/src/backend/parser/parse_collate.c:127: note: assign_query_collations_walker defined here
> #0 0x55c8ee0ffbd8 in query_tree_walker_impl /srv/dev/build/postgres/m-dev-assert-clang-sanitizer/../../../../../home/andres/src/postgresql/src/backend/nodes/nodeFuncs.c:2712:6

Ugh. So they're enforcing the C standard's position that "void *" is
not compatible with anything else. That makes this check useless to
us. We already decided that we're not going to take the hit of
declaring all walker/mutator callbacks with "void *", and I don't see
that this tool changes that decision.

> On https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html I found
> -fsanitize=function, which also can be used as -fno-sanitize=function:
>> -fsanitize=function: Indirect call of a function through a function pointer of the wrong type.
> With that I can get past this issue.

Good.

> I wish the sanitizer treated mismatches of void * arguments against a "real
> type" different from other mismatches, but ...

Indeed. I think we have enough coverage of that via compile-time
checks, though -- it's not like the type match or mismatch will vary
dynamically.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2025-03-03 21:58:07 Re: Ubsan complaint on kestrel
Previous Message Robert Haas 2025-03-03 21:01:11 Re: Showing primitive index scan count in EXPLAIN ANALYZE (for skip scan and SAOP scans)