Skip to content

Commit

Permalink
Mark fread's init function as static (#6328)
Browse files Browse the repository at this point in the history
* 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 <rtobar@icrar.org>

* rm ws

* correct placement

---------

Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>
Co-authored-by: Michael Chirico <chiricom@google.com>
  • Loading branch information
3 people authored Jul 31, 2024
1 parent b8d5f83 commit 488bdd2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/fread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 488bdd2

Please sign in to comment.