Skip to content

Commit 5e5b03c

Browse files
aitapTysonStanley
authored andcommitted
Mark internal_error and friends as __noreturn__ (#7071)
* Mark internal_error and friends as __noreturn__ This prevents a false-positive warning seen with GCC -fsanitize=... where an allocation checked using internal_error() is considered to be possibly of size zero. Fixes: #7070 * NEWS item * NEWS entry, actually link to the issue Adapted for patch release
1 parent c608875 commit 5e5b03c

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

NEWS.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
**If you are viewing this file on CRAN, please check [latest news on GitHub](https://github.com/Rdatatable/data.table/blob/master/NEWS.md) where the formatting is also better.**
22

3+
# data.table [v1.17.8](https://github.com/Rdatatable/data.table/milestone/41) (6 July 2025)
4+
5+
1. Internal functions used to signal errors are now marked as non-returning, silencing a compiler warning about potentially unchecked allocation failure. Thanks to Prof. Brian D. Ripley for the report and @aitap for the fix, [#7070](https://github.com/Rdatatable/data.table/pull/7070).
6+
37
# data.table [v1.17.6](https://github.com/Rdatatable/data.table/milestone/40) (15 June 2025)
48

59
1. On a heavily loaded machine, a `forder` thread could try to perform a zero-length copy from a null pointer, which was de-facto harmless but is against the C standard and was caught by additional CRAN checks, [#7051](https://github.com/Rdatatable/data.table/issues/7051). Thanks to @helske for the report and @aitap for the PR.
@@ -25,11 +29,8 @@
2529
6. Custom binary operators from the `lubridate` package now work with objects of class `IDate` as with a `Date` subclass, [#6839](https://github.com/Rdatatable/data.table/issues/6839). Thanks @emallickhossain for the report and @aitap for the fix.
2630

2731
7. `as.data.table()` now properly handles keys: specifying keys sets them, omitting keys preserves existing ones, and setting `key=NULL` clears them, [#6859](https://github.com/Rdatatable/data.table/issues/6859). Thanks @brookslogan for the report and @Mukulyadav2004 for the fix.
28-
29-
30-
## NOTES
3132

32-
1. Continued work to remove non-API C functions, [#6180](https://github.com/Rdatatable/data.table/issues/6180). Thanks Ivan Krylov for the PRs and for writing a clear and concise guide about the R API: https://aitap.codeberg.page/R-api/.
33+
8. Continued work to remove non-API C functions, [#6180](https://github.com/Rdatatable/data.table/issues/6180). Thanks Ivan Krylov for the PRs and for writing a clear and concise guide about the R API: https://aitap.codeberg.page/R-api/.
3334

3435
## BUG FIXES
3536

src/data.table.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@
8484
#define NEED2UTF8(s) !(IS_ASCII(s) || (s)==NA_STRING || IS_UTF8(s))
8585
#define ENC2UTF8(s) (!NEED2UTF8(s) ? (s) : mkCharCE(translateCharUTF8(s), CE_UTF8))
8686

87+
// R has been providing a widely portable definition, but since that's not documented, define our own too
88+
#ifndef NORET
89+
# if defined(__GNUC__) && __GNUC__ >= 3
90+
# define NORET __attribute__((__noreturn__))
91+
# else
92+
# define NORET
93+
# endif
94+
#endif
95+
8796
// init.c
8897
extern SEXP char_integer64;
8998
extern SEXP char_ITime;
@@ -153,7 +162,7 @@ uint64_t dtwiddle(double x);
153162
SEXP forder(SEXP DT, SEXP by, SEXP retGrpArg, SEXP retStatsArg, SEXP sortGroupsArg, SEXP ascArg, SEXP naArg);
154163
SEXP forderReuseSorting(SEXP DT, SEXP by, SEXP retGrpArg, SEXP retStatsArg, SEXP sortGroupsArg, SEXP ascArg, SEXP naArg, SEXP reuseSortingArg); // reuseSorting wrapper to forder
155164
int getNumericRounding_C(void);
156-
void internal_error_with_cleanup(const char *call_name, const char *format, ...);
165+
NORET void internal_error_with_cleanup(const char *call_name, const char *format, ...);
157166

158167
// reorder.c
159168
SEXP reorder(SEXP x, SEXP order);
@@ -269,7 +278,7 @@ SEXP islockedR(SEXP x);
269278
bool need2utf8(SEXP x);
270279
SEXP coerceUtf8IfNeeded(SEXP x);
271280
SEXP coerceAs(SEXP x, SEXP as, SEXP copyArg);
272-
void internal_error(const char *call_name, const char *format, ...);
281+
NORET void internal_error(const char *call_name, const char *format, ...);
273282

274283
// types.c
275284
char *end(char *start);

0 commit comments

Comments
 (0)