alter_fp_rounding_mode Is Not Panic Safe
- Lingua principale
- Rust
- Stelle
- 9.3k
- Fork
- 2.4k
- Merge medio
- 3g 11h
- PR unite (30g)
- 360
Descrizione
### Describe the bug
alter_fp_rounding_mode makes use of `fesetround` in order to alter the rounding mode on various architectures
```
let current = fegetround();
fesetround(if UPPER { FE_UPWARD } else { FE_DOWNWARD });
let result = operation(lhs, rhs);
fesetround(current);
result
```
Unfortunately if `operation` panics, `fesetround` will never revert the rounding mode. `Drop` would be a more reliable way around this, although there are still situations where `Drop` may not be called
### To Reproduce
_No response_
### Expected behavior
Ideally we wouldn't modify global thread-local state at all, but I'm not sure if this can be avoided
### Additional context
_No response_
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia individuando alter_fp_rounding_mode e tracciando il suo utilizzo di fesetround nelle architetture supportate. Riproduci il percorso di panic attorno a operation e determina se la modalità di arrotondamento viene ripristinata successivamente; il lavoro è completato quando la gestione di panic non lascia alterata la modalità di arrotondamento locale al thread, nel rispetto dei vincoli della piattaforma descritti nell’issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100