Odin icon indicating copy to clipboard operation
Odin copied to clipboard

Compiler segfaults when using a specific return tuple and values

Open hstormo opened this issue 4 years ago • 1 comments

Context

  • Operating System: Linux 5.13.19-2-MANJARO x86_64
  • Please paste odin version output: dev-2021-10:7aac8df2

Code:

package main
main :: proc() {
    a, b := foo()
}
foo :: proc() -> (^int, cstring) {
    return nil, ""
}

Backtrace:

Thread 1 "odin" received signal SIGSEGV, Segmentation fault.
0x00007ffff2dbb36e in LLVMGetConstOpcode () from /usr/lib/libLLVM-11.so
(gdb) bt
#0  0x00007ffff2dbb36e in LLVMGetConstOpcode () from /usr/lib/libLLVM-11.so
#1  0x00005555556c9c0c in lb_get_const_string (m=0x7fffc49a2678, value=...) at src/llvm_backend_const.cpp:79
#2  0x0000555555696c2e in lb_emit_conv (p=0x7fffc49a72c0, value=..., t=0x555555823730 <basic_types+4096>) at src/llvm_backend_expr.cpp:928
#3  0x00005555556d9365 in lb_build_return_stmt (p=0x7fffc49a72c0, return_results=...) at src/llvm_backend_stmt.cpp:1605
#4  0x00005555556e8d4d in lb_build_stmt (p=0x7fffc49a72c0, node=0x7fffed0f2e50) at src/llvm_backend_stmt.cpp:2127
#5  0x00005555556e7f41 in lb_build_stmt_list (p=0x7fffc49a72c0, stmts=...) at src/llvm_backend_stmt.cpp:150
#6  0x00005555556e8529 in lb_build_stmt (p=0x7fffc49a72c0, node=0x7fffed0f2ed0) at src/llvm_backend_stmt.cpp:2059
#7  0x00005555557089c9 in lb_generate_procedure (m=0x7fffc49a2678, p=0x7fffc49a72c0) at src/llvm_backend.cpp:1092
#8  0x000055555570b93c in lb_generate_code (gen=0x7fffc49a2590) at src/llvm_backend.cpp:1584
#9  0x000055555571ff5f in main (arg_count=3, arg_ptr=0x7fffffffe618) at src/main.cpp:2477

Expected Behavior

The code should compile fine.

Current Behavior

The compiler crashes with a segfault.

Failure Information (for bugs)

Seems to only happen when returning a pointer and a cstring, and using the nil, "" default values. I can replace any of the return values with {} and it compiles fine.

Steps to Reproduce

Build the code above.

hstormo avatar Oct 19 '21 14:10 hstormo

Hello!

I am marking this issue as stale as it has not received any engagement from the community or maintainers 120 days. That does not imply that the issue has no merit! If you feel strongly about this issue

  • open a PR referencing and resolving the issue;
  • leave a comment on it and discuss ideas how you could contribute towards resolving it;
  • leave a comment and describe in detail why this issue is critical for your use case;
  • open a new issue with updated details and a plan on resolving the issue.

The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone..

github-actions[bot] avatar Jul 24 '22 21:07 github-actions[bot]