Repository navigation
backport .rs.digest move to Tools.R and adler32 rewrite - #17799
Conversation
The async data-preview subprocess (R_PROCESS_VANILLA, launched from SessionData.cpp) sources only Tools.R plus a handful of session modules and has no RStudio embedding registered. The SHA-256-backed .rs.digest added in #17595 lived in SessionRUtil.R (not sourced in the subprocess) and called into rs_sha256 via the embedding (not available there either), so the column-names fingerprint failed with "could not find function '.rs.digest'" on any Import Dataset preview. The fingerprint just needs a stable identity token for collision detection, not a cryptographic hash, so move .rs.digest to Tools.R and implement it as a vectorized Adler-32 in pure base R. The chunked int32 closed form keeps all intermediate sums within R's signed 32-bit range, and pinning serialize(version = 2L) with the writer-version field zeroed keeps the hash stable across R upgrades. Drops the now-unused rs_sha256 C++ helper and its Crypto.hpp include. Addresses #17777.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Code ReviewThe core change is correct and clean. I validated the new Adler-32 against a byte-at-a-time reference in R 4.6.0 -- canonical vectors ( Two findings, both cases where the backport is narrower than #17789 on Important1. The riskiest new code ships to a release branch untested. The chunked-integer Adler-32 reformulation (the Recommend backporting those three test blocks into 2. Dead hash <- .rs.digest(nms)
if (is.na(hash))
return(NA_character_)and its doc comment still claims a return path "when the digest helper itself fails." The new Adler-32 Recommended action
Both items stem from the backport being narrower than its source PR; addressing them brings |
Intent
Addresses #17777. Backports the minimal
.rs.digestchanges from #17789 torel-golden-wattle.preview_data_import_async(inSessionData.cpp) spawns a--vanillaR subprocess to run the preview off the main session. That subprocess sources onlyTools.Rplus a handful of session modules and has no RStudio embedding registered. The SHA-256-backed.rs.digestadded in #17595 lived inSessionRUtil.R(not sourced there) and called intors_sha256via the embedding (also not available), so any CSV/readr/readxl/haven preview failed with:The data viewer fingerprint just needs a stable, bounded identity token for collision detection, not a cryptographic hash. This change:
.rs.digestfromSessionRUtil.RtoTools.R(already sourced by the subprocess).serialize(version = 2L)and zeros out bytes 7-10 (the writer's R version field) so the hash is stable across R upgrades. v2 chosen over v3 because v3 additionally embeds the native encoding name in the header, which can vary by platform.rs_sha256C++ helper and itsCrypto.hppinclude..rs.digestkeeps the same API (raw or arbitrary R value in, fixed-size hex string out), so existing callers work unchanged.Scope
This is the minimal
.rs.digest-focused subset of #17789. The adjacent cleanups bundled into that PR (thers_fromJSONPACKAGE qualifier, the deadINTEGER_OR_NULLdlopen removal, therstudio-testsTTY auto-wrap, the Playwright test hardening, and the new E2E test) are intentionally not included here.Upgrade note
The fingerprint format changes from
n:sha256(#17595) ton:adler32. Any saved per-object data-viewer state (pin/width/sort/filter) carrying the old anchor will mismatch on first launch and get discarded -- a one-time UI-state reset, no data loss. Since #17595 is still in the open Golden Wattle milestone, no released build is affected.