Skip to content

Commit 8f09f0c

Browse files
committed
common: fix ubsan trigger in param test.
``` common/test/run-param.c:381:8: runtime error: applying zero offset to null pointer SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior common/test/run-param.c:381:8 ``` Probably because CI now on 24.04, so more recent clang. But the test really does want to see what happens when the callback is NULL, so workaround. Signed-off-by: Rusty Russell <[email protected]>
1 parent 2bba6f0 commit 8f09f0c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

common/test/run-param.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,18 @@ static void bad_programmer(void)
376376
p_req("repeat", param_millionths, &fpval), NULL);
377377
assert(paramcheck_assert_failed);
378378

379+
/* UBSan gets upset with doing arith on NULL pointers, inside
380+
* the p_req macro, so we do it raw here */
381+
#define p_req_raw(name, cbx, arg) \
382+
name"", \
383+
PARAM_REQUIRED, \
384+
NULL, NULL, \
385+
(param_cbx)(cbx), \
386+
(arg)
387+
379388
paramcheck_assert_failed = false;
380389
param(cmd, j->buffer, j->toks,
381-
p_req("u64", (param_cbx) NULL, NULL), NULL);
390+
p_req_raw("u64", NULL, NULL), NULL);
382391
assert(paramcheck_assert_failed);
383392

384393
/* Add required param after optional */

0 commit comments

Comments
 (0)