Odin
Odin copied to clipboard
compiler crash on proc call with named generic
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
- Operating System & Odin Version:
- Please paste
odin reportoutput:
Odin: dev-2022-07-nightly:1676c643
OS: Manjaro Linux, Linux 5.18.12-3-MANJARO
CPU: AMD Ryzen 5 3600X 6-Core Processor
RAM: 15919 MiB
Expected Behavior
the following program compiles fine:
package crash
main::proc(){
a:=make(T=map[string]string)
// a:=make_map(T=map[string]string) // this one also crashes
}
Current Behavior
compiler crashes, without any warning (ran this command in zsh)
$ odin build crash.odin -file
zsh: segmentation fault (core dumped) odin build crash.odin -file
Failure Information (for bugs)
Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.
Steps to Reproduce
just try to compile the program above
Failure Logs
running with valgrind:
$ valgrind odin build crash.odin -file
==34324== Memcheck, a memory error detector
==34324== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==34324== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==34324== Command: odin build crash.odin -file
==34324==
==34324== Invalid read of size 4
==34324== at 0x4DE3F0: check_get_params(CheckerContext*, Scope*, Ast*, bool*, long*, bool*, long*, Array<Operand>*) (in /usr/lib/odin/odin)
==34324== by 0x492778: check_procedure_type(CheckerContext*, Type*, Ast*, Array<Operand>*) (in /usr/lib/odin/odin)
==34324== by 0x491E8F: find_or_generate_polymorphic_procedure(CheckerContext*, Entity*, Type*, Array<Operand>*, Ast*, PolyProcData*) (in /usr/lib/odin/odin)
==34324== by 0x4A962E: check_named_call_arguments(CheckerContext*, Ast*, Type*, Entity*, Array<Operand>, CallArgumentErrorMode, CallArgumentData*) (in /usr/lib/odin/odin)
==34324== by 0x4ACB5F: check_call_arguments(CheckerContext*, Operand*, Type*, Ast*, Slice<Ast*> const&) (in /usr/lib/odin/odin)
==34324== by 0x4B01CE: check_call_expr(CheckerContext*, Operand*, Ast*, Ast*, Slice<Ast*> const&, ProcInlining, Type*) (in /usr/lib/odin/odin)
==34324== by 0x4D0FC0: check_expr_base_internal(CheckerContext*, Operand*, Ast*, Type*) (in /usr/lib/odin/odin)
==34324== by 0x4A4EBB: check_expr_base(CheckerContext*, Operand*, Ast*, Type*) (in /usr/lib/odin/odin)
==34324== by 0x4A77A5: check_unpack_arguments(CheckerContext*, Entity**, long, Array<Operand>*, Slice<Ast*> const&, bool, bool) (in /usr/lib/odin/odin)
==34324== by 0x4E3DCB: check_init_variables(CheckerContext*, Entity**, long, Slice<Ast*> const&, String) (in /usr/lib/odin/odin)
==34324== by 0x4EEF83: check_stmt_internal(CheckerContext*, Ast*, unsigned int) (in /usr/lib/odin/odin)
==34324== by 0x4EBA63: check_stmt_list(CheckerContext*, Slice<Ast*> const&, unsigned int) (in /usr/lib/odin/odin)
==34324== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==34324==
==34324==
==34324== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==34324== Access not within mapped region at address 0x0
==34324== at 0x4DE3F0: check_get_params(CheckerContext*, Scope*, Ast*, bool*, long*, bool*, long*, Array<Operand>*) (in /usr/lib/odin/odin)
==34324== by 0x492778: check_procedure_type(CheckerContext*, Type*, Ast*, Array<Operand>*) (in /usr/lib/odin/odin)
==34324== by 0x491E8F: find_or_generate_polymorphic_procedure(CheckerContext*, Entity*, Type*, Array<Operand>*, Ast*, PolyProcData*) (in /usr/lib/odin/odin)
==34324== by 0x4A962E: check_named_call_arguments(CheckerContext*, Ast*, Type*, Entity*, Array<Operand>, CallArgumentErrorMode, CallArgumentData*) (in /usr/lib/odin/odin)
==34324== by 0x4ACB5F: check_call_arguments(CheckerContext*, Operand*, Type*, Ast*, Slice<Ast*> const&) (in /usr/lib/odin/odin)
==34324== by 0x4B01CE: check_call_expr(CheckerContext*, Operand*, Ast*, Ast*, Slice<Ast*> const&, ProcInlining, Type*) (in /usr/lib/odin/odin)
==34324== by 0x4D0FC0: check_expr_base_internal(CheckerContext*, Operand*, Ast*, Type*) (in /usr/lib/odin/odin)
==34324== by 0x4A4EBB: check_expr_base(CheckerContext*, Operand*, Ast*, Type*) (in /usr/lib/odin/odin)
==34324== by 0x4A77A5: check_unpack_arguments(CheckerContext*, Entity**, long, Array<Operand>*, Slice<Ast*> const&, bool, bool) (in /usr/lib/odin/odin)
==34324== by 0x4E3DCB: check_init_variables(CheckerContext*, Entity**, long, Slice<Ast*> const&, String) (in /usr/lib/odin/odin)
==34324== by 0x4EEF83: check_stmt_internal(CheckerContext*, Ast*, unsigned int) (in /usr/lib/odin/odin)
==34324== by 0x4EBA63: check_stmt_list(CheckerContext*, Slice<Ast*> const&, unsigned int) (in /usr/lib/odin/odin)
==34324== If you believe this happened as a result of a stack
==34324== overflow in your program's main thread (unlikely but
==34324== possible), you can try to increase the size of the
==34324== main thread stack using the --main-stacksize= flag.
==34324== The main thread stack size used in this run was 8388608.
==34324==
==34324== HEAP SUMMARY:
==34324== in use at exit: 76,842,930 bytes in 63,830 blocks
==34324== total heap usage: 83,498 allocs, 19,668 frees, 79,227,867 bytes allocated
==34324==
==34324== LEAK SUMMARY:
==34324== definitely lost: 158,480 bytes in 2,731 blocks
==34324== indirectly lost: 256 bytes in 2 blocks
==34324== possibly lost: 463,104 bytes in 28 blocks
==34324== still reachable: 76,221,090 bytes in 61,069 blocks
==34324== suppressed: 0 bytes in 0 blocks
==34324== Rerun with --leak-check=full to see details of leaked memory
==34324==
==34324== For lists of detected and suppressed errors, rerun with: -s
==34324== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
zsh: segmentation fault (core dumped) valgrind odin build crash.odin -file
this program (without make_map) on the other hand compiles (and runs) fine:
package crash
import "core:fmt"
myfunc::proc($T:typeid)->T{
r:T
return r
}
main::proc(){
a:=myfunc(T=int)
fmt.println(a)
}