Double free on calling __$startup_runtime
Context
The internal function __$startup_runtime appears to be the function that is called to initialize the global structs and arrays that are being put into bss section on startup. Since odin doesn't have freestanding target, in certain places the compiler assumes that there is a small portion of Odin runtime that is ran before the main code is ran. When Odin adds a freestanding target the problem of initializing the runtime and global variables will remain in some form, so this bug would have become relevant by then any way.
- Operating System & Odin Version: xubuntu
- Please paste
odin reportoutput: dev-2022-02:546faab0
Expected Behavior
We'll create a program that calls __$startup_runtime directly.
foreign _ {
@(link_name="__$startup_runtime")
startup_runtime :: proc "c" () ---;
}
@(export)
my_startup :: proc "c" () {
startup_runtime();
}
And compile with the following flags:
odin build kernel -build-mode:obj \
-disable-assert \
-no-crt \
-no-bounds-check \
-default-to-nil-allocator \
-out:something.o
Current Behavior
The compiler crashes with the following error message:
free(): double free detected in tcache 2
Aborted (core dumped)
Expected behaviour
The compiler successfully compiles the code, and in the compiled binary the address of the relocation for startup_runtime call is __$startup_runtime.
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..