-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Indefinite spawning of jbang processes with incorrect javaagent parameter settings #1803
Comments
This is not a jbang problem, but always happens when you put an |
@quintesse OK, but I couldn't reproduce the issue with #!/usr/bin/env echo &
echo hello $ ./echo.sh
/usr/bin/env: ‘echo &’: No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines Could you suggest me how to reproduce it with |
Make sure you leave everything else the same as with your "rampage" test. Just change |
In fact the command isn't even important, see:
|
@quintesse Thanks. I learnt that I now see that it's indeed not an issue with jbang. At the same time, jbang users may encounter the same issue especially when they play with |
I doubt it, it's just how Unix shells work. But knowing the symptoms next time we can at least tell users what they're doing wrong :-) |
Btw, I finally understand what's happening exactly. What is getting run is:
which is the same as running:
which is the same as:
So the shell runs JBang with wrong parameters which causes it to print out its usage message and then the shell runs the next command which sets the "port" environment variable to "8888" and runs "rampage.java" again which starts the entire loop anew. |
Thanks for your analysis! So the line below literally creates infinite loop with any given command.
It's very interesting. |
Describe the bug
It appears that if we accidentally include
&
in the--javaagent
parameter tojbang
at the beginning of a file, it goes on a rampage and spawns jbang processes indefinitely, which easily exhausts CPU resources on a laptop and leads to a DoS.Why does jbang try to restart indefinitely?
An example parameter that causes the issue:
///usr/bin/env jbang --javaagent=org.jolokia:jolokia-agent-jvm:2.0.2:javaagent=host=0.0.0.0&port=8888 "$0" "$@" ; exit $?
This is actually a correct, expected parameter (
,
instead of&
):///usr/bin/env jbang --javaagent=org.jolokia:jolokia-agent-jvm:2.0.2:javaagent=host=0.0.0.0,port=8888 "$0" "$@" ; exit $?
To Reproduce
Steps to reproduce the behavior:
rampage.java
:chmod u+x rampage.java
as follows:./rampage.java
Caution
Trying to reproduce the issue can easily cause a flood of jbang processes and your computer may easily be out of control. After that, you can only hit
ctrl+c
many times and/or commandpkill java
/pkill dev.jbang.Main
to quell the script.Expected behavior
It should only spawn one jbang process and stop immediately throwing some error that tells the
javaagent
parameter is wrong.JBang version
Paste output of
jbang version --verbose
Additional context
n/a
The text was updated successfully, but these errors were encountered: