Repository navigation
grass.script: Stop get_install_path from starting grass recursively - #8125
Draft
petrasovaa wants to merge 1 commit into
Draft
petrasovaa wants to merge 1 commit into
petrasovaa wants to merge 1 commit into
Conversation
The grass command calls get_install_path() when its compiled-in path does not exist, and get_install_path() runs the grass command as a last resort, so a wrong PYTHONPATH started processes without end. Mark the queried process in its environment and do not query from there. Written with assistance from Claude.
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 happened to me while using Claude to run tests, I am not entirely sure how important this is, on the other hand, it crashed my computer, so better to avoid this. Opening as draft because I didn't have time to scrutinize this very much myself.
get_install_path()could startgrass --config path, which callsget_install_path(), which startsgrass --config pathagain, without end. One wrongPYTHONPATHwas enough to flood a machine with thousands of processes. The query now marks its child process so the child does not query again.Details
Problem
The
grassstartup script reads its install prefix fromgrass.app.resource_paths. When that path does not exist, it callsget_install_path(), which tries the relative path and then, as a last resort, runsgrass --config pathand trusts the answer. If that executable is the same script in the same broken state, the sequence repeats, and every level is a new Python interpreter.This happens with the source tree first on
PYTHONPATH, since the placeholders inresource_paths.pyare only substituted in the built copy. It is an easy mistake when testing uncommitted changes.Change
get_install_path()setsGRASS_INSTALL_PATH_QUERYin the environment of the subprocess it starts. When the variable is already present, it skips all three executable queries (explicit path,GRASSBIN,grassonPATH) and returns the unresolved path, so the startup script fails with its normal error instead of recursing. No API change.Test
A new test writes a fake
grassexecutable that itself callsget_install_path()and asserts it runs exactly once. The fake refuses to go deeper than three levels, so a broken guard fails the test rather than flooding the system. Skipped on Windows because it relies on a shebang.Written with assistance from Claude.