From 488bdd2e068e4e56444916b75a61e029d3d4d296 Mon Sep 17 00:00:00 2001 From: rtobar Date: Thu, 1 Aug 2024 01:40:41 +0800 Subject: [PATCH] Mark fread's init function as static (#6328) * Mark fread's init function as static The function isn't used elsewhere, and making it publicly accessible opens the door for runtime linking issues -- where the function is served by other libraries exposing the same function. This was seen in a HPC cluster with software built with spack: 0 0x00001555513d8ce0 in init () from /opt/cray/pe/lib64/libsci_gnu_82_mpi.so.5 1 0x00001555433f46ba in parse_double_extended (...) at fread.c:819 2 0x00001555433f3e97 in detect_types (...) at fread.c:1203 3 0x00001555433f7959 in freadMain (...) at fread.c:1852 4 0x00001555433fd84d in freadR (...) at fRead.c:217 Signed-off-by: Rodrigo Tobar * rm ws * correct placement --------- Signed-off-by: Rodrigo Tobar Co-authored-by: Michael Chirico Co-authored-by: Michael Chirico --- NEWS.md | 2 ++ src/fread.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index d104981f6..83f48d685 100644 --- a/NEWS.md +++ b/NEWS.md @@ -184,6 +184,8 @@ This feature resolves [#4387](https://github.com/Rdatatable/data.table/issues/43 23. `set()` now adds new columns even if no rows are updated, [#5409](https://github.com/Rdatatable/data.table/issues/5409). This behavior is now consistent with `:=`, thanks to @mb706 for the report and @joshhwuu for the fix. +24. The internal `init()` function in `fread.c` module has been marked as `static`, [#6328](https://github.com/Rdatatable/data.table/pull/6328). This is to avoid name collisions, and the resulting segfaults, with other libraries that might expose the same symbol name, and be already loaded by the R process. This was observed in Cray HPE environments where the `libsci` library providing LAPACK to R already has an `init` symbol. Thanks to @rtobar for the report and fix. + ## TRANSLATIONS 1. Fix a typo in a Mandarin translation of an error message that was hiding the actual error message, [#6172](https://github.com/Rdatatable/data.table/issues/6172). Thanks @trafficfan for the report and @MichaelChirico for the fix. diff --git a/src/fread.c b/src/fread.c index e301e8cd1..45efa6eeb 100644 --- a/src/fread.c +++ b/src/fread.c @@ -84,7 +84,7 @@ static double NAND; static double INFD; // NAN and INFINITY constants are float, so cast to double once up front. -void init(void) { +static void init(void) { NAND = (double)NAN; INFD = (double)INFINITY; }