[R-pkg-devel] Warnings related to functions from the survival package

Ivan Krylov |kry|ov @end|ng |rom d|@root@org
Fri Nov 1 17:40:58 CET 2024


On Fri, 1 Nov 2024 09:56:01 +0100
Tomas Kalibera <tomas.kalibera using gmail.com> wrote:

> isn't there a finer-grained way to suppress reports just 
> of this particular issue, ideally at finer granularity than a
> function?

The line saying "function:do_dotCode" in the suppression file will
suppress errors just for mismatched function pointer types inside
do_dotCode(), because "function" is the name of this check [1]. Here's
do_dotCode with a different error added:

bin/R -q -s -e 'library(survival); survdiff(Surv(futime, fustat) ~
rx,data=ovarian)'

dotcode.c:1958:9: runtime error: 1e+100 is outside the range of
representable values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior dotcode.c:1958:9
dotcode.c:2012:2: runtime error: call to function survdiff2 through
pointer to incorrect function type
'void (*)(void *, void *, void *, void *, void *, void *, void *, void
*, void *, void *, void *, void
*, void *)'
/tmp/RtmpVPlRnI/R.INSTALL65eb26c0356f/survival/src/survdiff2.c:10:
note: survdiff2 defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior dotcode.c:2012:2

UBSAN_OPTIONS="suppressions=$(realpath dotcode.supp)" \
bin/R -q -s -e 'library(survival); survdiff(Surv(futime, fustat) ~
rx,data=ovarian)'

dotcode.c:1958:9: runtime error: 1e+100 is outside the range of
representable values of type 'int'

I don't think UBSan can suppress errors in a more precise manner. The
documentation only mentions files, functions ans libraries. Best I
could find was a 2020 comment [2] suggesting to separate the offending
code into a function and let the optimiser inline it.

-- 
Best regards,
Ivan

[1]
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#runtime-suppressions

[2]
https://bugs.llvm.org/show_bug.cgi?id=19834#c11



More information about the R-package-devel mailing list