ironpython3
ironpython3 copied to clipboard
Incorrect argument in function select() causes stack overflow
This piece of code leads to a stack overflow. The execution of the program stops at stacktrace. See the following reporting information. I think the problem may be related to recursion, the code basically ends up with an unlimited number of iterations of select.select and test_select_mutated on the call stack and this doesn't trigger the stack depth checker.
test.py
import select
def test_select_mutated():
a = []
class F:
def fileno(a):
del test_select_mutated()[-1]
return sys.__stdout__.fileno()
a[:] = [F()] * 10
select.select([], a, []), ([], a[:5], [])
test_select_mutated()
Environmental:
IronPython 3.4.0a1 (3.4.0.0001)
[.NETFramework,Version=v4.6 on Mono 6.12.0.122 (tarball Mon Feb 22 17:28:32 UTC 2021) (64-bit)] on linux
Error report:
(base) xxm@xxm-System-Product-Name:~$ ipy test.py
Stack overflow in unmanaged: IP: 0x718dd9, fault addr: 0x7ffcd96beff8
Stack overflow: IP: 0x7f734c953bce, fault addr: 0x7ffcd96b6fc8
Stacktrace:
at <unknown> <0xffffffff>
This one also kills the CPython interpreter.
Yes, I also reported it to CPython developers, They comment that this bug may be fixed by adding a stack depth check.
CPython bug report: https://bugs.python.org/issue44718