Skip to content

Conversation

@jserv
Copy link
Contributor

@jserv jserv commented Jan 18, 2026

Stripped ELFs lack symbol tables, so the 'exit' symbol cannot be found and exit_addr remains uninitialized. This caused on_exit to never become true, resulting in spurious error messages when crt0 calls close(0,1,2) during program termination.

Changes:

  • Add exit_addr check in syscall_close to allow close(fd<3) when no exit symbol was found (stripped ELF case)
  • Explicitly initialize exit_addr to 0 before symbol lookup
  • Also check for '_exit' symbol as fallback for different toolchains

Summary by cubic

Fix false close(fd<3) errors when running stripped ELFs by properly handling missing exit symbols and avoiding uninitialized exit_addr use. This prevents noisy logs when crt0 closes stdin/stdout/stderr on exit.

  • Bug Fixes
    • Initialize exit_addr to 0 before symbol lookup.
    • Resolve exit address by checking "exit" and falling back to "_exit".
    • In syscall_close, only flag fd<3 closes as errors if on_exit is false and exit_addr is set; otherwise allow them silently for stripped ELFs.

Written for commit 674f9d9. Summary will update on new commits.

Stripped ELFs lack symbol tables, so the 'exit' symbol cannot be found
and exit_addr remains uninitialized. This caused on_exit to never become
true, resulting in spurious error messages when crt0 calls close(0,1,2)
during program termination.

Changes:
- Add exit_addr check in syscall_close to allow close(fd<3) when no exit
  symbol was found (stripped ELF case)
- Explicitly initialize exit_addr to 0 before symbol lookup
- Also check for '_exit' symbol as fallback for different toolchains
@jserv jserv added this to the release-2026.1 milestone Jan 18, 2026
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Copy link
Contributor Author

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarks

Details
Benchmark suite Current: 674f9d9 Previous: b26939d Ratio
Dhrystone 1626 DMIPS 1597.333 DMIPS 0.98
CoreMark 971.664 iterations/sec 973.382 iterations/sec 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@jserv jserv merged commit 122ba2d into master Jan 18, 2026
33 checks passed
@jserv jserv deleted the fix-file-desc branch January 18, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants