Skip to content

fix: declare R_getRegisteredNamespace() so the C23 sanitizer build compiles#2749

Closed
krlmlr wants to merge 0 commit into
mainfrom
claude/fix-cicd-failures-63v5pe
Closed

fix: declare R_getRegisteredNamespace() so the C23 sanitizer build compiles#2749
krlmlr wants to merge 0 commit into
mainfrom
claude/fix-cicd-failures-63v5pe

Conversation

@krlmlr

@krlmlr krlmlr commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

LLM disclosure: this PR was prepared with Claude Code (Claude Opus 4.8).

  • By submitting this pull request, I assign the copyright of my contribution to The igraph development team.

What

Fix the R_getRegisteredNamespace compile error in the Sanitizer job of build-and-check.yml without changing the function used — the original call is correct.

Root cause (verified against the logs)

The R >= 4.6.0 fast path in src/rinterface_extra.c looks up the igraph namespace with R_getRegisteredNamespace("igraph") at three sites. That function is correct, public R API: Writing R Extensions documents it (@eapifun, "R 4.6.0 adds R_getRegisteredNamespace … find and return the namespace environment registered for a name") as the supported replacement for the non-API R_NamespaceRegistry, its signature is const char *, and it is a side-effect-free registry lookup (unlike R_FindNamespace(), which evaluates getNamespace() and loads the namespace).

The Sanitizer job builds against a CSAN R-devel image whose headers report R >= 4.6.0 (so the fast path is compiled) but predate the declaration being added to <Rinternals.h>. Proof from the same build log: R_getVar() — from the same header, added in R 4.5.0 — compiles, while R_getRegisteredNamespace() — added in R 4.6.0 — does not. Under clang -std=gnu2x (C23) an implicit declaration is a hard error:

rinterface_extra.c:2520:9: error: use of undeclared identifier 'R_getRegisteredNamespace'

libR does export the symbol — the non-C23 R-devel jobs (e.g. rcc: ubuntu-26.04 (devel)) compile and link the same call, only warning — so this is purely a missing header declaration on that one snapshot.

Fix

<Rinternals.h> is already included unconditionally via src/rinterface.h, and it is the only header that ever declares this entry point — so adding an #include cannot help a snapshot whose header lacks the line. Instead, declare the prototype locally in the R >= 4.6.0 branch:

extern SEXP R_getRegisteredNamespace(const char *name);
rho = R_getRegisteredNamespace("igraph");

It matches R's signature exactly, so it is a compatible redeclaration wherever the installed header already provides it, and it supplies the missing declaration where it does not. The R < 4.6.0 getNamespace() fallback is unchanged. Net change vs main: the prototype line (plus comments) at the three sites.

Verification

Reproduced locally with R 4.5.3 headers (which, like the CSAN snapshot, do not declare the function):

  • Without the prototype: error: implicit declaration of function 'R_getRegisteredNamespace' under gcc -std=gnu2x -Werror=implicit-function-declaration — the same failure as CI.
  • With the prototype: compiles clean (-Wall -Wextra -std=gnu2x).

The Sanitizer workflow is also dispatched against this branch to confirm end-to-end on the real CSAN image.

Not addressed here (separate, not this compile bug)

  • rcc: ubuntu-26.04 (4.2) / (4.3)pak resolution fails on removed Bioconductor releases (Enhances: graph) 404ing on the Posit mirror. Environmental.
  • rcc: * (devel) check failures — those jobs compile fine (examples run); they fail later in R CMD check on an R-devel check condition unrelated to this compile error.

🤖 Generated with Claude Code

@krlmlr
krlmlr force-pushed the claude/fix-cicd-failures-63v5pe branch from db3422a to dbf1f50 Compare July 22, 2026 20:58
@krlmlr krlmlr changed the title fix: drop non-API R_getRegisteredNamespace() to fix R-devel C23 build fix: use public R_FindNamespace() for the igraph namespace lookup Jul 23, 2026
@krlmlr
krlmlr force-pushed the claude/fix-cicd-failures-63v5pe branch from 9bf5e75 to 96802ac Compare July 23, 2026 15:10
@krlmlr krlmlr changed the title fix: use public R_FindNamespace() for the igraph namespace lookup fix: keep R 4.6.0 API R_getRegisteredNamespace(), from the correct include Jul 23, 2026
@krlmlr
krlmlr force-pushed the claude/fix-cicd-failures-63v5pe branch from 96802ac to 0bf1b77 Compare July 23, 2026 15:32
@krlmlr krlmlr changed the title fix: keep R 4.6.0 API R_getRegisteredNamespace(), from the correct include fix: use R_FindNamespace() so the C23 sanitizer build compiles Jul 23, 2026
@krlmlr
krlmlr force-pushed the claude/fix-cicd-failures-63v5pe branch from 0bf1b77 to cc2a927 Compare July 23, 2026 16:07
@krlmlr krlmlr changed the title fix: use R_FindNamespace() so the C23 sanitizer build compiles fix: declare R_getRegisteredNamespace() so the C23 sanitizer build compiles Jul 23, 2026
@krlmlr krlmlr closed this Jul 24, 2026
@krlmlr
krlmlr force-pushed the claude/fix-cicd-failures-63v5pe branch from cc2a927 to 0055d78 Compare July 24, 2026 09:22
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.

1 participant