Skip to content
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

infinite exception loop in sysFatal leads to out-of-memory #9657

Closed
arnetheduck opened this issue Nov 9, 2018 · 2 comments · Fixed by #9783
Closed

infinite exception loop in sysFatal leads to out-of-memory #9657

arnetheduck opened this issue Nov 9, 2018 · 2 comments · Fixed by #9783

Comments

@arnetheduck
Copy link
Contributor

ah, the joys of exceptions.. nim 0.19ish.

sysFatal calls write that raises an exception that causes sysfatal to be called etc in an infinite loop that eventually eats all memory, when stderr is closed (for example when killing a parent process)

#308 0x0000000000413cf6 in sysFatal_nMottChWknXyAhGA1fBmOAsystem (message=0x7cbb60 <TM_Q5wkpxktOdTGvlSRo9bzt9aw_32>) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5881
#309 0x0000000000413d50 in raiseEIO_PpfSiTIeNpMAb9a5o6SglJw (msg=0x7cbb60 <TM_Q5wkpxktOdTGvlSRo9bzt9aw_32>) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5888
#310 0x0000000000413e08 in checkErr_BWnr8V7RERYno9bIdPmw8Hw (f=0x7fc51b6666a0 <_IO_2_1_stderr_>) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5905
#311 0x0000000000413e4a in write_ADGLlEJAOtGNWWur8rrJfg (f=0x7fc51b6666a0 <_IO_2_1_stderr_>, 
    c=0x7fc298203040 "nlvm.nim(161)", ' ' <repeats 12 times>, "nlvm\nnlvm.nim(150)", ' ' <repeats 12 times>, "handleCmdLine\nnlvm.nim(77)", ' ' <repeats 13 times>, "mainCommand\nnlvm.nim(52)", ' ' <repeats 13 times>, "commandLL\nmodules.nim(126)         compileProject\nmodules.nim(71)    "...) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5916
#312 0x0000000000413e6f in writeToStdErr_7HRVfGfZT2rSmBdcLxl8TA (
    msg=0x7fc298203040 "nlvm.nim(161)", ' ' <repeats 12 times>, "nlvm\nnlvm.nim(150)", ' ' <repeats 12 times>, "handleCmdLine\nnlvm.nim(77)", ' ' <repeats 13 times>, "mainCommand\nnlvm.nim(52)", ' ' <repeats 13 times>, "commandLL\nmodules.nim(126)         compileProject\nmodules.nim(71)    "...) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5920
#313 0x0000000000413ec1 in showErrorMessage_rsUJ87b89bH0GlWKYL9c8wUQ (
    data=0x7fc298203040 "nlvm.nim(161)", ' ' <repeats 12 times>, "nlvm\nnlvm.nim(150)", ' ' <repeats 12 times>, "handleCmdLine\nnlvm.nim(77)", ' ' <repeats 13 times>, "mainCommand\nnlvm.nim(52)", ' ' <repeats 13 times>, "commandLL\nmodules.nim(126)         compileProject\nmodules.nim(71)    "...) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5934
#314 0x00000000004139fc in raiseExceptionAux_na8C8pUZ9cLQWVwk35l5vfw (e=0x7fc297d3bf30) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5827
#315 0x0000000000413c08 in raiseExceptionEx (e=0x7fc297d3bf30, ename=0x7cd01b "IOError", procname=0x7ccfba "sysFatal", filename=0x7ccfc3 "../Nim/lib/system.nim", line=2970) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5865
#316 0x0000000000413cf6 in sysFatal_nMottChWknXyAhGA1fBmOAsystem (message=0x7cbb60 <TM_Q5wkpxktOdTGvlSRo9bzt9aw_32>) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5881
#317 0x0000000000413d50 in raiseEIO_PpfSiTIeNpMAb9a5o6SglJw (msg=0x7cbb60 <TM_Q5wkpxktOdTGvlSRo9bzt9aw_32>) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5888
#318 0x0000000000413e08 in checkErr_BWnr8V7RERYno9bIdPmw8Hw (f=0x7fc51b6666a0 <_IO_2_1_stderr_>) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5905
#319 0x0000000000413e4a in write_ADGLlEJAOtGNWWur8rrJfg (f=0x7fc51b6666a0 <_IO_2_1_stderr_>, 
    c=0x7fc297db6040 "nlvm.nim(161)", ' ' <repeats 12 times>, "nlvm\nnlvm.nim(150)", ' ' <repeats 12 times>, "handleCmdLine\nnlvm.nim(77)", ' ' <repeats 13 times>, "mainCommand\nnlvm.nim(52)", ' ' <repeats 13 times>, "commandLL\nmodules.nim(126)         compileProject\nmodules.nim(71)    "...) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5916
#320 0x0000000000413e6f in writeToStdErr_7HRVfGfZT2rSmBdcLxl8TA (
    msg=0x7fc297db6040 "nlvm.nim(161)", ' ' <repeats 12 times>, "nlvm\nnlvm.nim(150)", ' ' <repeats 12 times>, "handleCmdLine\nnlvm.nim(77)", ' ' <repeats 13 times>, "mainCommand\nnlvm.nim(52)", ' ' <repeats 13 times>, "commandLL\nmodules.nim(126)         compileProject\nmodules.nim(71)    "...) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5920
#321 0x0000000000413ec1 in showErrorMessage_rsUJ87b89bH0GlWKYL9c8wUQ (
    data=0x7fc297db6040 "nlvm.nim(161)", ' ' <repeats 12 times>, "nlvm\nnlvm.nim(150)", ' ' <repeats 12 times>, "handleCmdLine\nnlvm.nim(77)", ' ' <repeats 13 times>, "mainCommand\nnlvm.nim(52)", ' ' <repeats 13 times>, "commandLL\nmodules.nim(126)         compileProject\nmodules.nim(71)    "...) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5934
#322 0x00000000004139fc in raiseExceptionAux_na8C8pUZ9cLQWVwk35l5vfw (e=0x7fc2978efbd0) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5827
#323 0x0000000000413c08 in raiseExceptionEx (e=0x7fc2978efbd0, ename=0x7cd01b "IOError", procname=0x7ccfba "sysFatal", filename=0x7ccfc3 "../Nim/lib/system.nim", line=2970) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5865
#324 0x0000000000413cf6 in sysFatal_nMottChWknXyAhGA1fBmOAsystem (message=0x7cbb60 <TM_Q5wkpxktOdTGvlSRo9bzt9aw_32>) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5881
#325 0x0000000000413d50 in raiseEIO_PpfSiTIeNpMAb9a5o6SglJw (msg=0x7cbb60 <TM_Q5wkpxktOdTGvlSRo9bzt9aw_32>) at /home/arnetheduck/.cache/nim/nlvm_d/stdlib_system.c:5888
@alaviss
Copy link
Collaborator

alaviss commented Nov 11, 2018

Here's a small test case

close stderr
stderr.writeLine "Error"

@alaviss
Copy link
Collaborator

alaviss commented Nov 11, 2018

And here's the culprit:

proc writeToStdErr(msg: cstring) = write(stdmsg, msg)

I think the error message writer should be annotated with {.raises: [].}...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants