Repository navigation
valgrind issue in 1.18.0 #7546
Description
Activity
- There are two separate issues. One is that under Valgrind, data.table::frollsd(c(1e8+2.980232e-8, 1e8, 1e8, 1e8), 3) returns c(NA, NA, 1.82501207499443e-08, 1.82501207499443e-08) instead of c(NA, NA, 1.72058537479884e-08, 0). This should be solved by #7548, although base R doesn't struggle with computing sd(c(1e8, 1e8, 1e8)) to be 0 under Valgrind. The other is that when frollmedian(1:10, 3) tries to compare if (n[A]!=tail && m[A] == n[A]) { at froll.c:1710, n[0] is uninitialised: (gdb) p A $26 = 0 (gdb) p m $27 = (int *) 0x8875700 (gdb) monitor xb 0x8875700 4 00 00 00 00 <-- all valid 0x8875700: 0x02 0x00 0x00 0x00 (gdb) p n $28 = (int *) 0x88c6140 (gdb) monitor xb 0x88c6140 4 ff ff ff ff <-- whole word invalid 0x88C6140: 0x00 0x00 0x00 0x00 Possibly because the assignment at froll.c:1622 if (even) n[j] = o[j*k+h+1]; was skipped due to 'even' being false.
R doesn't struggle with computing sd(c(1e8, 1e8, 1e8)) to be 0 under Valgrind.
Gemini helped me with the intuition here:
- We shouldn't expect the same result as
sd(x)because, for efficiency, we use the previous window's results and update. So thec(1e8+eps, 1e8, 1e8)window's tiny variance "taints" the calculation for thec(1e8, 1e8, 1e8)window. - And then it's just a matter of tolerances/numerical error. On full-precision platforms, there's probably still a tiny non-0 value in the
fastresult, but small enoughall.equal()passes. But when switching to 53 bytes, the tiny difference becomes too large & bubbles out.
- We shouldn't expect the same result as
There are two separate issues.
One is that under Valgrind, data.table::frollsd(c(1e8+2.980232e-8, 1e8,
1e8, 1e8), 3) returns c(NA, NA, 1.82501207499443e-08,
1.82501207499443e-08) instead of c(NA, NA, 1.72058537479884e-08, 0).
This should be solved by #7548, although base R doesn't struggle with
computing sd(c(1e8, 1e8, 1e8)) to be 0 under Valgrind.The other is that when frollmedian(1:10, 3) tries to compare
if (n[A]!=tail && m[A] == n[A]) {
at froll.c:1710, n[0] is uninitialised:
(gdb) p A
$26 = 0
(gdb) p m
$27 = (int *) 0x8875700
(gdb) monitor xb 0x8875700 4
00 00 00 00 <-- all valid
0x8875700: 0x02 0x00 0x00 0x00
(gdb) p n
$28 = (int *) 0x88c6140
(gdb) monitor xb 0x88c6140 4
ff ff ff ff <-- whole word invalid
0x88C6140: 0x00 0x00 0x00 0x00Possibly because the assignment at froll.c:1622
if (even) n[j] = o[j*k+h+1];was skipped due to 'even' being false.
The second one is still not resolved afaik
Reacted by aitap- added 2 commits that reference this issue
on Jan 12, 2026 - added a commit that references this issue
on Jan 14, 2026 - added a commit that references this issue
on Jan 15, 2026 - added a commit that references this issue
on Jan 27, 2026
From CRAN:
https://www.stats.ox.ac.uk/pub/bdr/memtests/valgrind/data.table/00check.log
Possibly, it just means we need to include another test to be skipped: