[BUG] libuv makes sim/macOS crash
- Dominant language
- C
- Stars
- 4k
- Forks
- 1.7k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 237
Description
### Description / Steps to reproduce the issue
libuv crashes (a NULL dereference) as the following on sim/macOS. (macOS 15.2, x86-64, Xcode 16.1)
that is, the constructor is called too early it seems.
while we have a mechanism to defer constructor calls on sim,
there are at least two problems:
* the mechanism is tied to C++. (the code in question is in C, not C++)
* it doesn't work for the latest macOS (https://github.com/apache/nuttx/issues/15208)
```
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xa8)
* frame #0: 0x0000000100007f15 nuttx`nxsched_get_stackinfo(pid=0, stackinfo=0x00007ff7bfee96d8) at sched_get_stackinfo.c:103:38
frame #1: 0x000000010002e0d9 nuttx`tls_get_info at tls_getinfo.c:64:9
frame #2: 0x000000010002e0a6 nuttx`task_get_info at task_getinfo.c:52:33
frame #3: 0x000000010002b92c nuttx`atexit_register(type=4, func=(nuttx`uv_library_shutdown at uv-common.c:941), arg=0x0000000000000000, dso=0x0000000100113328) at lib_atexit.c:70:36
frame #4: 0x000000010002bc4a nuttx`__cxa_atexit(func=(nuttx`uv_library_shutdown at uv-common.c:941), arg=0x0000000000000000, dso_handle=0x0000000100113328) at lib_atexit.c:270:10
frame #5: 0x00000001000fccb8 nuttx`__GLOBAL_init_65535 + 24
frame #6: 0x00007ff8045d2729 dyld`invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 241
frame #7: 0x00007ff80460b4e9 dyld`invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 241
frame #8: 0x00007ff8045ffb73 dyld`invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 543
frame #9: 0x00007ff8045ba07b dyld`dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 249
frame #10: 0x00007ff8045febe8 dyld`dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 176
frame #11: 0x00007ff80460b0d4 dyld`dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 470
frame #12: 0x00007ff8045d25c2 dyld`dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 150
frame #13: 0x00007ff8045d8af7 dyld`dyld4::JustInTimeLoader::runInitializers(dyld4::RuntimeState&) const + 21
frame #14: 0x00007ff8045d2928 dyld`dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array&, dyld3::Array&) const + 276
frame #15: 0x00007ff8045d6141 dyld`dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const::$_0::operator()() const + 147
frame #16: 0x00007ff8045d29bc dyld`dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const + 90
frame #17: 0x00007ff8045ee1f7 dyld`dyld4::APIs::runAllInitializersForMain() + 277
frame #18: 0x00007ff8045bf52e dyld`dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 3433
frame #19: 0x00007ff8045be792 dyld`dyld4::start(dyld4::KernelArgs*, void*, void*)::$_0::operator()() const + 572
frame #20: 0x00007ff8045be27f dyld`start + 1727
(lldb)
```
### On which OS does this issue occur?
[OS: Mac]
### What is the version of your OS?
macOS 15.2
### NuttX Version
master
### Issue Architecture
[Arch: simulator]
### Issue Area
[Area: Other]
### Verification
- [X] I have verified before submitting the report.
Contributor guide
Assessment
This issue has not been assessed yet.