Commit 45c49e6
committed
[yugabyte#27447] YSQL: avoid ASAN failure in multirange code
Summary:
Running Java test TestPgRegressPgTypesUDT on ASAN fails with
ts1|pid74720|:24411 ${YB_SRC_ROOT}/src/postgres/src/include/lib/sort_template.h:301:15: runtime error: applying non-zero offset 8 to null pointer
ts1|pid74720|:24411 #0 0x55eb30c5c61b in qsort_arg ${YB_SRC_ROOT}/src/postgres/src/include/lib/sort_template.h:301:15
ts1|pid74720|:24411 #1 0x55eb30883c9a in multirange_canonicalize ${YB_SRC_ROOT}/src/postgres/src/backend/utils/adt/multirangetypes.c:481:2
ts1|pid74720|:24411 #2 0x55eb30883c9a in make_multirange ${YB_SRC_ROOT}/src/postgres/src/backend/utils/adt/multirangetypes.c:648:16
ts1|pid74720|:24411 #3 0x55eb2ffd01db in ExecInterpExpr ${YB_SRC_ROOT}/src/postgres/src/backend/executor/execExprInterp.c:731:8
...
ts1|pid74720|:24411 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ${YB_SRC_ROOT}/src/postgres/src/include/lib/sort_template.h:301:15
ts1|pid74720|:24411 2025-05-30 04:15:01.687 UTC [74992] WARNING: server process (PID 76254) exited with exit code 1
ts1|pid74720|:24411 2025-05-30 04:15:01.687 UTC [74992] DETAIL: Failed process was running: select textmultirange();
pg_regress|pid75085|stdout test yb.port.multirangetypes ... FAILED (test process exited with exit code 2) 1615 ms
The issue is that multirange_constructor0 passes NULL, which flows all
the way down to qsort_arg, and qsort_arg attempts pointer arithmetic on
that NULL. Fix by returning early before that.
This fix may impact other cases besides multirange since qsort_arg is
used in several places, but given no issues were reported till now,
perhaps it isn't possible to pass NULL to qsort_arg through those
places.
Jira: DB-16985
Test Plan:
On Almalinux 8:
./yb_build.sh asan daemons initdb \
--java-test 'org.yb.pgsql.TestPgRegressPgTypesUDT#schedule'
Close: yugabyte#27447
Reviewers: telgersma
Reviewed By: telgersma
Subscribers: yql
Differential Revision: https://phorge.dev.yugabyte.com/D444641 parent d86bf40 commit 45c49e6
1 file changed
+9
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
299 | 308 | | |
300 | 309 | | |
301 | 310 | | |
| |||
0 commit comments