Skip to content

fread signed integer overflow on gcc-UBSAN and clang-UBSAN checks #6729

@TaikiSan21

Description

@TaikiSan21

My package on CRAN (PAMscapes) recently got flagged because there is an error triggered in both the gcc-UBSAN and clang-UBSAN additional CRAN checks. Here is a link to the check page, here is some version info from the check log:

  • using R Under development (unstable) (2025-01-15 r87580)
  • using platform: x86_64-pc-linux-gnu
  • R was compiled by
    clang version 19.1.6
    flang-new version 19.1.6
  • running under: Fedora Linux 36 (Workstation Edition)
  • using session charset: UTF-8
  • using option ‘--no-stop-on-test-error’

And here is copy of the error message from the Ex-out:

fread.c:1919:30: runtime error: signed integer overflow: 237281 * 237281 cannot be represented in type 'int'
#0 0x7fee3c6f9969 in freadMain /tmp/Rtmp8p0OKk/R.INSTALLecbd63f70502d/data.table/src/fread.c:1919:30
#1 0x7fee3c70e547 in freadR /tmp/Rtmp8p0OKk/R.INSTALLecbd63f70502d/data.table/src/freadR.c:218:3
#2 0x55b4d6c2342b in R_doDotCall (/data/gannet/ripley/R/R-clang/bin/exec/R+0xf342b)
#3 0x55b4d6c23d1d in do_dotcall (/data/gannet/ripley/R/R-clang/bin/exec/R+0xf3d1d)
#4 0x55b4d6c5ffe2 in bcEval_loop eval.c
#5 0x55b4d6c5971b in bcEval eval.c
#6 0x55b4d6c58ea4 in Rf_eval (/data/gannet/ripley/R/R-clang/bin/exec/R+0x128ea4)
#7 0x55b4d6c719c1 in R_execClosure eval.c
#8 0x55b4d6c70eab in applyClosure_core eval.c
#9 0x55b4d6c592f5 in Rf_eval (/data/gannet/ripley/R/R-clang/bin/exec/R+0x1292f5)
#10 0x55b4d6c77006 in do_set (/data/gannet/ripley/R/R-clang/bin/exec/R+0x147006)
#11 0x55b4d6c590cf in Rf_eval (/data/gannet/ripley/R/R-clang/bin/exec/R+0x1290cf)
#12 0x55b4d6ca6e20 in Rf_ReplIteration (/data/gannet/ripley/R/R-clang/bin/exec/R+0x176e20)
#13 0x55b4d6ca87be in run_Rmainloop (/data/gannet/ripley/R/R-clang/bin/exec/R+0x1787be)
#14 0x55b4d6ca882a in Rf_mainloop (/data/gannet/ripley/R/R-clang/bin/exec/R+0x17882a)
#15 0x55b4d6b97a27 in main (/data/gannet/ripley/R/R-clang/bin/exec/R+0x67a27)
#16 0x7fee4fa2950f in __libc_start_call_main (/lib64/libc.so.6+0x2950f) (BuildId: 8257ee907646e9b057197533d1e4ac8ede7a9c5c)
#17 0x7fee4fa295c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x295c8) (BuildId: 8257ee907646e9b057197533d1e4ac8ede7a9c5c)
#18 0x55b4d6b97944 in _start (/data/gannet/ripley/R/R-clang/bin/exec/R+0x67944)

The only thing I am doing in my package is reading this CSV file using fread with the option header=TRUE.

# Minimal reproducible example; please be sure to set verbose=TRUE where possible!
I've tried but been unable to reproduce this - I don't have access to a Linux machine, and I don't really understand the UBSAN section in the writing R extensions manual. I've tried running package checks using the rhub package's clang-asan container that is meant to mimic these CRAN checks, but the same example ran without error. I'm not exactly sure where to go from here, but figured y'all might have better ideas.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions