playframework / playframework/play1
[1.4.5] `subprocess.Popen` in Python script might throw OS exception on large `java_cmd` values
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 671
- Avg merge
- 12d 15h
- Merged PRs (30d)
- 1
Description
There is an OS limitation on the size of command parameters in Linux (1/4 of stack size, explained here).
Wherever Play 1.4.5 is doing something like:
try:
process = subprocess.Popen (java_cmd, env=os.environ)
signal.signal(signal.SIGTERM, handle_sigterm)
return_code = process.wait()
signal.signal(signal.SIGINT, handle_sigint)
if 0 != return_code:
sys.exit(return_code)
except OSError:
print "Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/java). "
sys.exit(-1)
The exception messaging would end up being misleading. JAVA_HOME is just fine. java_cmd is too long and an exception is thrown.
More informative exceptions make things a bit better:
except OSError as err:
print("OS error: {0}".format(err))
print "~ Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/jav\
a). "
print "~ "
sys.exit(-1)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in framework/pym/play/commands/base.py around line 148 and inspect how subprocess.Popen handles OSError when executing java_cmd. Reproduce the large-argument failure on Linux, then verify that the resulting message distinguishes an oversized command from an invalid JAVA_HOME without obscuring the original OS error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100