Odin
Odin copied to clipboard
Segfault on inner procedure combined with generics
Context
Odin: dev-2022-03:68b74eb7 OS: Linux Mint 20.1, Linux 5.4.0-58-generic CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz RAM: 7812 MiB
Expected Behavior
Allow inner procedures to use generics without crashing silently
Current Behavior
Crashes early when building, doesn't produce a binary
Steps to Reproduce
isolated
call :: proc(value: $T) {
}
main :: proc() {
a := proc(msg: string) {
Test :: struct {}
call(Test {}) // <--
}
}
found while using json
import "core:encoding/json"
main :: proc() {
a := proc(msg: string) {
Test :: struct { // has to be a struct
testing: int,
}
test: Test
json.unmarshal_string(msg, &test)
}
}
Failure Logs
Both examples segfault early
I am reproducing on OpenBSD too.
It segfaults due to failing assert GB_ASSERT(proc->kind == Entity_Procedure).
Thread 1 received signal SIGSEGV, Segmentation fault.
0x0000014da01ba035 in lb_set_nested_type_name_ir_mangled_name (e=0x15050e80720, p=0x0) at src/llvm_backend_general.c
1273 GB_ASSERT(proc->kind == Entity_Procedure);
(gdb) bt
#0 0x0000014da01ba035 in lb_set_nested_type_name_ir_mangled_name (e=0x15050e80720, p=0x0) at src/llvm_backend_gener1273
#1 0x0000014da01ba7e5 in lb_get_entity_name (m=0x15050fe7258, e=0x15050e80720, default_name=...) at src/llvm_backenal.cpp:1317
#2 0x0000014da01bc1bf in lb_type_internal (m=0x15050fe7258, type=0x15050e80fc0) at src/llvm_backend_general.cpp:161
#3 0x0000014da0191fe2 in lb_type (m=0x15050fe7258, type=0x15050e80fc0) at src/llvm_backend_general.cpp:2013
#4 0x0000014da01bdb04 in lb_type_internal (m=0x15050fe7258, type=0x15050e80b10) at src/llvm_backend_general.cpp:191
#5 0x0000014da0191fe2 in lb_type (m=0x15050fe7258, type=0x15050e80b10) at src/llvm_backend_general.cpp:2013
#6 0x0000014da01c0f47 in lb_create_procedure (m=0x15050fe7258, entity=0x15050e814f0, ignore_body=false) at src/llvmd_proc.cpp:122
#7 0x0000014da021bb64 in lb_generate_code (gen=0x15050fe7170) at src/llvm_backend.cpp:1686
#8 0x0000014da0231c2c in main (arg_count=3, arg_ptr=0x7f7ffffbc258) at src/main.cpp:2665
correcting myself: it failed because of segfault in the assert line: proc is NULL do deferencing it (for testing the assert) fails.
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..