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

Invalid memory access using the interpreter in file_spec #13739

Closed
beta-ziliani opened this issue Aug 9, 2023 · 2 comments · Fixed by #14381
Closed

Invalid memory access using the interpreter in file_spec #13739

beta-ziliani opened this issue Aug 9, 2023 · 2 comments · Fixed by #14381
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:interpreter

Comments

@beta-ziliani
Copy link
Member

When executing crystal i spec/std/file_spec.cr (from the root of the project), it crashes after running successfully all the tests.

Maybe this is related to the fluke we see in CI?

My setup
Crystal 1.9.0-dev [1c186dc0e] (2023-06-29)

The compiler was not built in release mode.

LLVM: 15.0.7
Default target: x86_64-apple-macosx
Entire stacktrace
Invalid memory access (signal 11) at address 0x2d
[0x10d997e4b] *Exception::CallStack::print_backtrace:Nil +107 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10d960340] ~procProc(Int32, Pointer(LibC::SiginfoT), Pointer(Void), Nil)@src/crystal/system/unix/signal.cr:131 +304 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x7fff2089fd7d] _sigtramp +29 in /usr/lib/system/libsystem_platform.dylib
[0x10e89612a] *Crystal::Repl::Interpreter#interpret<Crystal::ASTNode+, Crystal::Type+>:Crystal::Repl::Value +375482 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10e839d61] *Crystal::Repl::Interpreter#interpret<Crystal::ASTNode+, Hash(String, Crystal::MetaVar)>:Crystal::Repl::Value +2289 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10eb8c2f3] *Crystal::Repl#interpret<Crystal::Call>:Crystal::Repl::Value +115 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10eb8c259] *Crystal::Repl#interpret_exit:Crystal::Repl::Value +41 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10eb8c208] *Crystal::Repl#run_file<String, Array(String)>:Crystal::Repl::Value +216 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10ed0bbb0] *Crystal::Command#repl:(Crystal::Repl::Value | Nil) +1440 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10ed05cc7] *Crystal::Command#run:(Bool | Crystal::Repl::Value | Nil) +1159 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10ed056cc] *Crystal::Command::run<Array(String)>:(Bool | Crystal::Repl::Value | Nil) +44 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10ed0564e] *Crystal::Command::run:(Bool | Crystal::Repl::Value | Nil) +46 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10d9362de] __crystal_main +2750 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10db44734] *Crystal::main_user_code<Int32, Pointer(Pointer(UInt8))>:Nil +36 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10db4468b] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +59 in /Users/beta/projects/crystal/crystal/.build/crystal
[0x10d9436b9] main +9 in /Users/beta/projects/crystal/crystal/.build/crystal
@beta-ziliani beta-ziliani added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:interpreter labels Aug 9, 2023
@straight-shoota
Copy link
Member

I can reproduce this with compiler version 1c186dc. But this is an old version before 1.9.0.
With a current compiler build (1.9.2) there is no error. So this was probably fixed somewhere down the line.

@HertzDevil
Copy link
Contributor

HertzDevil commented Mar 21, 2024

For a long time I thought this was a Windows-only issue, but I guess it isn't?

It looks like when the interpreter compiles the ::exit call that it invokes explicitly, the STDOUT inside the body is somehow different from the top-level one, so STDOUT gets initialized twice. Commenting out STDOUT.flush makes the spec no longer crash. I have no idea why STDERR doesn't have the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:interpreter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants