withCreateProcess async exception safety
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- haskell
- Bereich
- operating-systems
Rechercherichtung
Beginne damit, withCreateProcess, cleanupProcess und waitForProcess zusammen mit der Diskussion von Control.Exception über unterbrechbare Operationen zu lesen. Untersuche, ob takeMVar, hClose oder andere Bereinigungsschritte unterbrochen werden können, und verwende die gemeldete Änderung an threadDelay nur als Diagnosewerkzeug. Als erledigt gilt die Aufgabe, wenn das Verhalten asynchroner Exceptions durch einen zuverlässigen Test festgestellt wurde oder die Bedenken schlüssig ausgeräumt sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
I'm concerned that withCreateProcess may fail to clean up if an async exception is received at just the wrong time. I do not have a test case to prove it, but my reasoning follows.
See Control.Exception's discussion of "Interruptible operations". The masking of async exceptions by bracket when cleanupProcess is running only prevents non-interruptable operations from receiving an async exception. So if any operation in cleanupProcess turns out to be interruptable, an async exception received during that operation will prevent the rest of it from running.
Looking at the operations that get run, there's a takeMVar, but I think the MVar is always full, so it's not interruptable. Then it closes the IO handles, and as far as I can see, hClose is interruptable, or at least is not documented not to be.
So, an async exception received just as hClose is run will terminate the thread, and waitForProcess will never wait on the process. (IO handles could also potentially be left open, although generally GC will auto-close them when they go out of scope.) It's probably a rather narrow race condition.
My analysis could be wrong, but eh, if I've been staring at this code for an hour and I don't know if it it's correct, it seems like it would be a good idea to make sure this doesn't happen by using uninterruptibleMask somewhere?
(The closest I have come to a test case is modifying cleanupProcess to add threadDelay 100, and then it's easy to time the async exception to interrupt it, leaving the process running. But of course it might be threadDelay itself that's the interruptable operation in that case.)
- Vorherrschende Sprache
- Haskell
- Sterne
- 91
- Forks
- 93
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus haskell/process
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
-
HAVE_PIPE2 at compile time but not at runtime causes segfault on macOSEvtl. vergeben @alt-romes hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
-
posix_spawn falls back to fork() when create_group = True due to HAVE_DECL_ macro mismatchEvtl. vergeben @lei-jia-xing hat das vor 11 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 57/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
Alle Issues in haskell/process
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
haskell/bytestring#730 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
seal-harness/seal-harness#399 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
fmidue/codeworld-tasks#124 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
reflex-frp/reflex#563 ·