Skip to content

Commit 49806a7

Browse files
authored
segfault in fread warning message fixed (#4724)
1 parent 5267157 commit 49806a7

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
3. Operating on columns of type `list`, e.g. `dt[, listCol[[1]], by=id]`, suffered a performance regression in v1.13.0, [#4646](https://github.com/Rdatatable/data.table/issues/4646) [#4658](https://github.com/Rdatatable/data.table/issues/4658). Thanks to @fabiocs8 and @sandoronodi for the detailed reports, and to Cole Miller for substantial debugging, investigation and proposals at C level which enabled the root cause to be fixed.
1616

17+
4. `fread("1.2\n", colClasses='integer')` would segfault when creating the warning message due to no column names in the output, [#4644](https://github.com/Rdatatable/data.table/issues/4644). It now warns with `Attempt to override column 1 of inherent type 'float64' down to 'int32' ignored.` When column names are present, the warning message includes the name as before; i.e., `fread("A\n1.2\n", colClasses='integer')` produces `Attempt to override column 1 <<A>> of inherent type 'float64' down to 'int32' ignored.`. Thanks to Kun Ren for reporting.
18+
19+
1720
## NOTES
1821

1922
1. `bit64` v4.0.2 and `bit` v4.0.3, both released on 30th July, broke `data.table`'s tests. It seems that reverse dependency testing of `bit64` (i.e. testing of the packages which use `bit64`) did not include `data.table` because `data.table` suggests `bit64` but does not depend on it. Like other packages on our `Suggest` list, we test `data.table` works with `bit64` in our tests. In testing of our own reverse dependencies (packages which use `data.table`) we do include packages which suggest `data.table`, although it appears it is not CRAN policy to do so. We have requested that CRAN policy be improved to include suggests in reverse dependency testing.

inst/tests/tests.Rraw

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17144,3 +17144,9 @@ test(2153.4, address(ans$V1[[1L]]), address(ans$V1[[2L]])) # .NGRP doesn't chan
1714417144
test(2153.5, DT[, .(list(c(0L,.N,0L))), by=x], # c() here will create new object so this is ok anyway; i.e. address(.N) is not present in j's result
1714517145
data.table(x=1:2, V1=list(c(0L,1L,0L), c(0L,2L,0L))))
1714617146

17147+
# warning message segfault when no column names present, #4644
17148+
test(2154.1, fread("0.0\n", colClasses="integer"), data.table(V1=0.0),
17149+
warning="Attempt to override column 1 of inherent type 'float64' down to 'int32' ignored.*please")
17150+
test(2154.2, fread("A\n0.0\n", colClasses="integer"), data.table(A=0.0),
17151+
warning="Attempt to override column 1 <<A>> of inherent type 'float64' down to 'int32' ignored.*please")
17152+

src/fread.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,8 +2064,9 @@ int freadMain(freadMainArgs _args) {
20642064
if (type[j]==CT_DROP) { size[j]=0; ndrop++; continue; }
20652065
if (type[j]<tmpType[j]) {
20662066
if (strcmp(typeName[tmpType[j]], typeName[type[j]]) != 0) {
2067-
DTWARN(_("Attempt to override column %d <<%.*s>> of inherent type '%s' down to '%s' ignored. Only overrides to a higher type are currently supported. If this was intended, please coerce to the lower type afterwards."),
2068-
j+1, colNames[j].len, colNamesAnchor+colNames[j].off, typeName[tmpType[j]], typeName[type[j]]);
2067+
DTWARN(_("Attempt to override column %d%s%.*s%s of inherent type '%s' down to '%s' ignored. Only overrides to a higher type are currently supported. If this was intended, please coerce to the lower type afterwards."),
2068+
j+1, colNames?" <<":"", colNames?(colNames[j].len):0, colNames?(colNamesAnchor+colNames[j].off):"", colNames?">>":"", // #4644
2069+
typeName[tmpType[j]], typeName[type[j]]);
20692070
}
20702071
type[j] = tmpType[j];
20712072
// TODO: apply overrides to lower type afterwards and warn about the loss of accuracy then (if any); e.g. "4.0" would be fine to coerce to integer with no warning since

0 commit comments

Comments
 (0)