I have found that when trying to use a function called 'echo' which
also calls the 'echo' builtin posh will hang while leaking several GBs
of memory and then segfaulting.
echo () { echo foo; } ; echo
When I rebuilt posh with '-O0 -g' the amount of memory its leaks is
much greater and it seems like I will run out of swap before it
segfaults, maybe this is an infinite loop?
When running posh in gdb and getting a backtrace while posh is leaking
memory by pressing ctrl+c I find that gdb will also enter an infinite
loop...
I have attached a very large backtrace compressed with xz and a short
example script that will demonstrate the problem. Please take care when
testing it.
Hello,
just tried to reproduce this issue.
And I think this is "just" a recursion.
Also bash shows this behaviour.
(except it just allocates 132MB instead of
exchausting the whole physical memory.)
Are you maybe trying to achive something like this?
echo () { /bin/echo foo; } ; echo
Kind regards,
Bernhard
Hello,
just tried to reproduce this issue.
And I think this is "just" a recursion.
Also bash shows this behaviour.
(except it just allocates 132MB instead of
exchausting the whole physical memory.)
Are you maybe trying to achive something like this?
echo () { /bin/echo foo; } ; echo
Kind regards,
Bernhard
Hi, I was trying to make a test case that shows how 'unset -f' is still broken, see this other issue. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911395 I thought I tested this in other shells, but I was apparently mistaken and you are right that bash shares this behavior with a far lesser severity. It seems most shells will just segfault immediately while a few actually handled this. $ ksh $ echo () { echo foo; }; echo ksh: echo: recursion too deep $ zsh % echo () { echo foo; }; echo echo: maximum nested function level reached; increase FUNCNEST Regardless, posh probably could handle this better, this could be a good way to bring down a system with posh installed...
After I spent time talking about this in #!/bin/mksh @ freenode I think the expected behavior is a segfault. The massive memory leak is potentially dangerous and this could fail in a safer way.