pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: John Naylor <johncnaylorls@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Undefined behavior detected by new clang's ubsan
Date: Tue, 20 Jan 2026 09:00:00 +0200
Message-ID: <7ea15f17-f001-4b5c-979d-b9cff4db46bb@gmail.com> (raw)
In-Reply-To: <CANWCAZbm1cZyNAmV+f-GBD3pa3F=Nx6x85mH-c4eS=-2us3OjQ@mail.gmail.com>
References: <777bd201-6e3a-4da0-a922-4ea9de46a3ee@gmail.com>
	<CANWCAZbm1cZyNAmV+f-GBD3pa3F=Nx6x85mH-c4eS=-2us3OjQ@mail.gmail.com>

Hello John,

20.01.2026 08:13, John Naylor wrote:
> On Tue, Jan 20, 2026 at 12:00 PM Alexander Lakhin <exclusion@gmail.com> wrote:
>> ../../src/include/lib/sort_template.h:314:15: runtime error: applying non-zero offset 8 to null pointer
>> SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../src/include/lib/sort_template.h:314:15
> Where does it think a NULL pointer is coming from?

Thank you for paying attention to this!

With UBSAN_OPTIONS=print_stacktrace=1, I can see:
     #0 0x607efd762a61 in qsort_arg .../src/port/../../src/include/lib/sort_template.h:314:15
     #1 0x607efd3fa268 in multirange_canonicalize .../src/backend/utils/adt/multirangetypes.c:488:2
     #2 0x607efd3fa268 in make_multirange .../src/backend/utils/adt/multirangetypes.c:655:16
     #3 0x607efcab820f in ExecInterpExpr .../src/backend/executor/execExprInterp.c:926:8
     #4 0x607efceef4b6 in ExecEvalExprSwitchContext 
.../src/backend/optimizer/util/../../../../src/include/executor/executor.h:444:13
     #5 0x607efceef4b6 in evaluate_expr .../src/backend/optimizer/util/clauses.c:5323:14
     #6 0x607efcef282f in evaluate_function .../src/backend/optimizer/util/clauses.c:4830:9
     #7 0x607efcef282f in simplify_function .../src/backend/optimizer/util/clauses.c:4179:12
     #8 0x607efcee84d9 in eval_const_expressions_mutator .../src/backend/optimizer/util/clauses.c:2608:14
     #9 0x607efccdda63 in expression_tree_mutator_impl .../src/backend/nodes/nodeFuncs.c:3485:5
     #10 0x607efcee60ba in eval_const_expressions_mutator .../src/backend/optimizer/util/clauses.c:3798:9
     #11 0x607efccde200 in expression_tree_mutator_impl .../src/backend/nodes/nodeFuncs.c:3571:12
     #12 0x607efcee60ba in eval_const_expressions_mutator .../src/backend/optimizer/util/clauses.c:3798:9
     #13 0x607efcee5d97 in eval_const_expressions .../src/backend/optimizer/util/clauses.c:2282:9
     #14 0x607efce76a8f in preprocess_expression .../src/backend/optimizer/plan/planner.c:1331:10
     #15 0x607efce73c32 in subquery_planner .../src/backend/optimizer/plan/planner.c:934:3
     #16 0x607efce6fbee in standard_planner .../src/backend/optimizer/plan/planner.c:470:9
     #17 0x607efce6f49a in planner .../src/backend/optimizer/plan/planner.c:324:12
     #18 0x607efd1ff680 in pg_plan_query .../src/backend/tcop/postgres.c:905:9
     #19 0x607efd1ff968 in pg_plan_queries .../src/backend/tcop/postgres.c:1000:11
     #20 0x607efd20a87b in exec_simple_query .../src/backend/tcop/postgres.c:1198:19
     #21 0x607efd204dc0 in PostgresMain .../src/backend/tcop/postgres.c
     #22 0x607efd1f804b in BackendMain .../src/backend/tcop/backend_startup.c:124:2
     #23 0x607efcf9e59a in postmaster_child_launch .../src/backend/postmaster/launch_backend.c:268:3
     #24 0x607efcfa8136 in BackendStartup .../src/backend/postmaster/postmaster.c:3606:8
     #25 0x607efcfa8136 in ServerLoop .../src/backend/postmaster/postmaster.c:1713:6
     #26 0x607efcfa46cc in PostmasterMain .../src/backend/postmaster/postmaster.c:1403:11
     #27 0x607efcc4ca92 in main .../src/backend/main/main.c:231:4
...
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../src/include/lib/sort_template.h:314:15
...
2026-01-20 08:20:18.256 EET postmaster[3914440] LOG:  client backend (PID 3914618) was terminated by signal 6: Aborted
2026-01-20 08:20:18.256 EET postmaster[3914440] DETAIL:  Failed process was running: select textmultirange();

Best regards,
Alexander





view thread (12+ messages)  latest in thread

Message-ID: <7ea15f17-f001-4b5c-979d-b9cff4db46bb@gmail.com>
Permalink:  ../7ea15f17-f001-4b5c-979d-b9cff4db46bb@gmail.com/
Also on:    postgresql.org/message-id/7ea15f17-f001-4b5c-979d-b9cff4db46bb@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: exclusion@gmail.com, johncnaylorls@gmail.com
  Subject: Re: Undefined behavior detected by new clang's ubsan
  In-Reply-To: <7ea15f17-f001-4b5c-979d-b9cff4db46bb@gmail.com>
  References: <777bd201-6e3a-4da0-a922-4ea9de46a3ee@gmail.com> <CANWCAZbm1cZyNAmV+f-GBD3pa3F=Nx6x85mH-c4eS=-2us3OjQ@mail.gmail.com> <7ea15f17-f001-4b5c-979d-b9cff4db46bb@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox