rust-lang / rust-lang/rust

Why does teeos panic during exit?

Open
#162,847 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug O-teeos T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I was reading the platform sources for the runtime and I found this peculiar sys::cleanup implementation on teeos (aarch64-unknown-teeos):

https://github.com/rust-lang/rust/blob/28e8a8c81bf3b37909edac6c2a76e56f30cd492f/library/std/src/sys/pal/teeos/mod.rs#L33-L38

This function is always invoked after main. The unsupported.rs implementation is to just do nothing, but this is panicking instead. Even if it is somehow intentional, an rtabort call would surely be much more appropriate in this context, given that unimplemented involves a call to the global allocator and panic hook.

It just looks wrong. Am I missing something?

@rustbot label T-libs O-teeos

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with library/std/src/sys/pal/teeos/mod.rs around the linked sys::cleanup implementation and compare it with the unsupported.rs behavior mentioned in the issue. Trace how cleanup is invoked after main and determine the intended failure behavior; done means the teeos implementation matches that intent without the reported panic-path concerns.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.