Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jangorecki
Copy link
Member

Closes #7546

Haven't tested, but looking at

Fri Dec 26 02:23:49 2025 endian==little, sizeof(long double)==16, capabilities('long.double')==TRUE, longdouble.digits==53, sizeof(pointer)==8, TZ==unset,

and

exact_NaN = isTRUE(capabilities()["long.double"]) && identical(as.integer(.Machine$longdouble.digits), 64L)

I think it should do

exact_NaN = isTRUE(capabilities()["long.double"]) && identical(as.integer(.Machine$longdouble.digits), 64L)
if (!exact_NaN) {
cat("\n**** Skipping 7 NaN/NA algo='exact' tests because .Machine$longdouble.digits==", .Machine$longdouble.digits, " (!=64); e.g. under valgrind\n\n", sep="")
cat("\n**** Skipping 8 NaN/NA algo='exact' tests because .Machine$longdouble.digits==", .Machine$longdouble.digits, " (!=64); e.g. under valgrind\n\n", sep="")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could do something like nskip for foreign messages to avoid incrementing this manually

if (foreign && nskip > 0L) catf("Skipped %d tests for translated messages. ", nskip) # nocov

@codecov
Copy link

codecov bot commented Dec 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.96%. Comparing base (291a711) to head (c524ccf).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7548      +/-   ##
==========================================
- Coverage   98.97%   98.96%   -0.02%     
==========================================
  Files          87       87              
  Lines       16733    16737       +4     
==========================================
+ Hits        16561    16563       +2     
- Misses        172      174       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

y = c(1e8+2.980232e-8, 1e8, 1e8, 1e8) # CLAMP0 test
test(6001.731, frollvar(y, 3)[4L], 0)
test(6001.732, frollsd(y, 3)[4L], 0)
if (exact_NaN) test(6001.732, frollsd(y, 3)[4L], 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the other cases are all using algo='exact', so this would be the first case being skipped with algo='fast'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's also v. interesting that frollvar(y, 3)[4L], which per glancing the implementation only differs by applying sqrt(), does not have this numerical difference issue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sqrt must be causing this rounding error

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could possibly use all.equal here instead... Then no need to escape test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why 2.980232e-8 was chosen? Maybe we could make that a function of .Machine$double.eps (assuming that changes on/off valgrind) or of .Machine$longdouble.digits?

Copy link
Member

@MichaelChirico MichaelChirico Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the CLAMP0 in the comment refers to something that was refactored...

#7361 (comment)

c2c5bde#diff-6eb444de657f71e8b89b3d686c4ec70e4ecff4e33154481d0b1b416d09449f1eL1140

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems @ben-schwen came up with that number:

#7361 (comment)

Copy link
Member

@ben-schwen ben-schwen Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.980232e-8 was chosen because without clamp, it produced wrong results. AFAIR I used rnorm with e-16 or smth and pushed onto frollsd until I found the example (with 3 or 4 other candidates) because the code looked numerically unstable (hitting negative numbers).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the extra context, very helpful. I did a similar exercise (with rnorm(1e6, sd=1e-8) to be precise) and found that, absent the clamping added in #7361, we can trigger the negative result on valgrind with a different epsilon:

y = c(1e8-0.000000017353503836151923775668, 1e8, 1e8, 1e8)
frollvar(y, 3)
# [1]            NA            NA  0.000000e+00 -1.110223e-16

But it does seem prohibitively difficult to come up with an epsilon that fails with and without valgrind, and I'm not sure there's anything but cleverness points to score there anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could possibly use all.equal here instead... Then no need to escape test

wound up doing essentially this, but all.equal() won't do because the intent of the test is to ensure the result is strictly non-negative.

@aitap aitap mentioned this pull request Dec 29, 2025
@MichaelChirico MichaelChirico merged commit 7d70b15 into master Jan 2, 2026
9 checks passed
@MichaelChirico MichaelChirico deleted the frollsd-non-exact branch January 2, 2026 21:14
MichaelChirico added a commit that referenced this pull request Jan 12, 2026
* escape one tests for valgrind

* increment skipped count

* escape proper one

* make test robust to valgrind numerical issues

---------

Co-authored-by: Michael Chirico <[email protected]>
@MichaelChirico MichaelChirico added this to the 1.18.2 milestone Jan 14, 2026
ben-schwen added a commit that referenced this pull request Jan 27, 2026
* 1.18.0 on CRAN. Bump to 1.18.99

* bump versions

* Fix milestone link for 1.18.2

* Replace `ATTRIB`, `SET_ATTRIB` (#7487)

* frev: drop SET_ATTRIB

Instead, backport and use CLEAR_ATTRIB (R >= 4.5).

* mergeIndexAttrib: drop SET_ATTRIB

Use SHALLOW_DUPLICATE_ATTRIB (R >= 3.3) for the simple case. Also,
Backport ANY_ATTRIB (R >= 4.5) instead of testing !isNull(ATTRIB(.)).

* cbindlist: use ANY_ATTRIB

* nafillR: use ANY_ATTRIB

* Backport R_mapAttrib

* anySpecialStatic: switch to R_mapAttrib

* dogroups: construct rownames anew

Instead of trying to walk ATTRIB in search of the compact 'rownames'
attribute to modify, install it anew, take note of the returned
reference to the value being installed (a different one!) and modify
that.

* mergeIndexAttrib: switch to R_mapAttrib

* assign: factor out index fixup

Instead of walking the attribute list directly, use R_mapAttrib().
Create a hash table of index names instead of relying on chin() and a
temporary string vector. Move all temporary allocations onto the R heap.

* assign: drop indexLength

* assign: fix index unmarking

* Comments, better field names

* Update src/dogroups.c

Co-authored-by: Benjamin Schwendinger <[email protected]>

* mapAttrib: protect the attribute value

Otherwise the callback could remove the attribute and end up with the
value unprotected. Protect the attribute tag as well for uniformity.

Co-Authored-By: HughParsonage <[email protected]>

* dogroups: look up rownames using mapAttrib

This solution is closer to the working approach previously taken by the code.

* Fix comment, function name

* Protect the newly found rownames attribute

* add NEWS entry

---------

Co-authored-by: HughParsonage <[email protected]>
Co-authored-by: Benjamin Schwendinger <[email protected]>
Co-authored-by: Michael Chirico <[email protected]>
Co-authored-by: Michael Chirico <[email protected]>

* use getVar over findVar (#7575)

* remove unused vars (#7578)

* Fix code blocks in NEWS.md (#7518)

Add a missing triple-backtick separator.

Separate the indented code blocks from the preceding paragraph because
otherwise Pandoc fails to realise that the whitespace followed by
triple-backtick denotes a fenced code block.

* make rchk happy (#7520)

Co-authored-by: Michael Chirico <[email protected]>

* escape one frollsd tests for valgrind (#7548)

* escape one tests for valgrind

* increment skipped count

* escape proper one

* make test robust to valgrind numerical issues

---------

Co-authored-by: Michael Chirico <[email protected]>

* fix(7571): bug fix for narm issue on gforce in int64 case (#7572)

* fix(7571): bug fix for narm issue on gforce in int64 case

* fix(7571): test sequencing

* fix(7571): updated the NEWS.md

* trailing newline

* Use $V1

* fix(7571): added db optimize 2L

* refine NEWS

* fix(7571): add more tests and change to code similar to int for gsum

* fix(7571): added more tests for mean

* eliminate intermediate variable

* NEWS again

---------

Co-authored-by: Michael Chirico <[email protected]>

* add @manmita (#7573)

* `utils.c`: include `<signal.h>` for `siginfo_t` (#7517)

* utils.c: include <signal.h> for siginfo_t

POSIX says:

> The <signal.h> header shall define the siginfo_t type as a structure

So <sys/wait.h> is not enough to see the definition (not just a forward
declaration) of siginfo_t.

* NEWS entry

* Amend NEWS

* more robustly define _POSIX_C_SOURCE (h/t Hugh)

* tidy up NEWS

* -D_POSIX_C_SOURCE=200809L in gitlab CI job for regression test

* revert gitlab-ci change

---------

Co-authored-by: Michael Chirico <[email protected]>
Co-authored-by: Michael Chirico <[email protected]>

* Remove unrelated release notes

Amend 1c05f11: remove the notes not
relevant to the 1.18.2 release.

* Fix http -> https link that is now a redirect (#7588)

Found the following (possibly) invalid URLs:
  URL: http://stereopsis.com/radix.html (moved to https://stereopsis.com/radix.html)
    From: man/setkey.Rd
          man/setorder.Rd
    Status: 200
    Message: OK

* Fix latest rchk issues (#7585)

* attempt PROTECT for new rchk issues

* different approach for longestLevels

* use nprotect?

* no longer using names SEXP

* only UNPROTECT near exit

* no, that cant be it...

* move assignment into loop

* REPROTECT approach

* reduce diff

* reduce diff

* set automatically allocates new column slots if needed (#7538)

* set automatically allocates new column slots if needed

* use GetOption1 instead of GetOption

* fix test

* change froll test

* remove assign change

* add output statements to test loop

* add helper function

* frollmedianFast: avoid reading uninitialised array (#7589)

The 'n' array is only initialised if 'even' is true, so skip the
comparisons otherwise. Detected by checking with --use-valgrind or
performing a frollmedian() with an odd window size under R -d valgrind.

Fixes: #7546

* `setlevels()`: avoid crash on missing factor values (#7596)

Check for missing or out of bounds values and set them to NA.

* Avoid out-of-bounds access in `overlaps` (#7598)

* Add tests

* overlaps: avoid accessing length-0 vectors in ux

If 'ux' contains 0 rows, pretend that all comparisons against its
non-existent elements fail.

* overlaps: avoid 'lookup' list overflow

This used to happen when from[i] was 0. (No match on non-range columns?)

* NEWS entry

* overlaps: uncomment one more underflow test

Technically this one was harmless (and thus not caught by sanitizers)
because the preceding VECSEXP header always contained a 0, preventing
the branch where VECTOR_ELT() would be called with a negative index.

* test formatting

* Update src/ijoin.c

Co-authored-by: Benjamin Schwendinger <[email protected]>

* Update src/ijoin.c

Co-authored-by: Benjamin Schwendinger <[email protected]>

* Update src/ijoin.c

Co-authored-by: Benjamin Schwendinger <[email protected]>

* Update inst/tests/tests.Rraw

* overlaps: uncomment the remaining underflow test

The underflow is covered by already existing tests.

---------

Co-authored-by: Benjamin Schwendinger <[email protected]>

* Only export R_init_data_table (#7607)

This will avoid name clashes between data.table functions (now hidden)
and other functions in the global namespace visible to the shared
library loader.

Fixes: #7605

* `set()`: only reallocate the table if resizing would fail otherwise (#7606)

* Regression tests

* set(): only reallocate if resizing would fail

* Update R/data.table.R

Co-authored-by: Michael Chirico <[email protected]>

* Rename test variables

Co-Authored-By: Michael Chirico <[email protected]>

* Cache j %chin% names(x)

Co-Authored-By: Benjamin Schwendinger <[email protected]

---------

Co-authored-by: Michael Chirico <[email protected]>
Co-authored-by: Michael Chirico <[email protected]>

* NEWS entry for #7607 (#7608)

* NEWS entry for #7607

* More about the problem being solved

Co-Authored-By: Benjamin Schwendinger <[email protected]>

* `tests/froll.R`: disable `mcparallel` under Valgrind (#7621)

* update NEWS

* fix merge

---------

Co-authored-by: Tyson Barrett <[email protected]>
Co-authored-by: aitap <[email protected]>
Co-authored-by: HughParsonage <[email protected]>
Co-authored-by: Michael Chirico <[email protected]>
Co-authored-by: Michael Chirico <[email protected]>
Co-authored-by: Jan Gorecki <[email protected]>
Co-authored-by: Manmita Das <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

valgrind issue in 1.18.0

3 participants