libgis: Fix G_init_locale recursion and add GISBASE fallback for resource dirs#28
Open
wenzeslaus wants to merge 2 commits into
Open
libgis: Fix G_init_locale recursion and add GISBASE fallback for resource dirs#28wenzeslaus wants to merge 2 commits into
wenzeslaus wants to merge 2 commits into
Conversation
G_locale_dir() calls G_fatal_error() when GRASS_LOCALEDIR is not set, and G_fatal_error() translates its message, which re-enters G_init_locale() and recurses until the stack overflows. Read the variable directly and skip bindtextdomain() when it is not set, matching the pre-existing behavior for GISBASE. Likely the cause of the g.proj stack overflow (0xC00000FD) seen on Windows CI in the FHS preparation PR. Found and fixed with Claude Code.
When a GRASS_* resource variable is not set, fall back to the legacy layout location relative to GISBASE so that environments created from GISBASE alone keep working with legacy installations. Fail fatally only when the variable is not set and the fallback directory does not exist, which is the case for an FHS installation without a properly created session. Verified with a bare-GISBASE environment: legacy build lists color rules through the fallback; FHS build reports the incomplete session error cleanly. Written with Claude Code.
wenzeslaus
force-pushed
the
fix-5630-locale-recursion
branch
from
July 12, 2026 15:19
967d466 to
e650ea6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the Windows CI failure in OSGeo#5630 and makes the new resource variables degrade gracefully, as offered in OSGeo#5630 (comment).
Two commits:
Avoid infinite recursion in
G_init_locale(). WhenGRASS_LOCALEDIRis unset,G_locale_dir()callsG_fatal_error(_(...)), and translating that message re-entersG_init_locale()before its initialized flag is set, recursing until the stack overflows. This is theg.projexit code 3221225725 (0xC00000FD, STATUS_STACK_OVERFLOW) on Windows CI; it only shows there because the OSGeo4W build configures--with-nlswhile the Ubuntu CI builds do not. The fix reads the variable directly and skipsbindtextdomain()when it is unset, matching the previous GISBASE-based behavior. Locale initialization must never be fatal, since fatal errors themselves translate messages.Fall back to GISBASE-relative paths in
get_g_env(). When aGRASS_*resource variable is unset, fall back to the legacy location relative toGISBASE, and fail fatally only when neither yields an existing path. This keeps environments constructed fromGISBASEalone (third-party launchers, oldergrass.scriptversions) working with legacy-layout installations, while an FHS installation without a properly created session still gets the clean "Incomplete GRASS session" error.Verified on a branch carrying these fixes on top of this PR's changes: legacy and FHS CMake builds complete, an installed tree passes session smoke tests, and a bare-GISBASE environment lists color rules through the fallback on the legacy build while the FHS build reports the incomplete-session error cleanly.
The diagnosis and the fixes were developed with Claude Code and reviewed and tested locally.