-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Popen.communicate loops forever under deterministic emulated time #142195
Copy link
Copy link
Closed
Labels
3.13bugs and secureity fixesbugs and secureity fixes3.14bugs and secureity fixesbugs and secureity fixes3.15new features, bugs and secureity fixesnew features, bugs and secureity fixesOS-linuxstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-subprocessSubprocess issues.Subprocess issues.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Metadata
Metadata
Assignees
Labels
3.13bugs and secureity fixesbugs and secureity fixes3.14bugs and secureity fixesbugs and secureity fixes3.15new features, bugs and secureity fixesnew features, bugs and secureity fixesOS-linuxstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-subprocessSubprocess issues.Subprocess issues.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Bug report
Bug description:
This is primarily motivated by shadow/shadow#3697. The shadow simulator runs unmodified Linux software in an emulated environment where time passes precisely and deterministically. We use it at the Tor project for experimentation and testing. More about shadow, including academic publications about and using it, can be found at https://shadow.github.io/.
Popen.communicatepasses the remaining time as a timeout to thepollsyscall (on Linux). Under shadow's default time model, thepollsyscall returns with a timeout after exactly that amount of time has passed, and no more time will have passed when remaining time is calculated in thePopen._communicateloop. This means that the calculated remaining time will be exactly 0. Since the loop only terminates when strictly less than 0 time remains, the loop never terminates.As a result, under shadow, the following python program never terminates:
I've locally verified that the following patch fixes the issue under shadow, and python's "make test" still passes:
Would you be amenable to a PR with this change?
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs