Skip to content

Commit 07638b9

Browse files
committed
bootstrap: Be resilient to job object failures
The build bots already use job objects, and they don't support nested job objects, and we shouldn't entirely bail out in this case anyway!
1 parent a1c13d0 commit 07638b9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/bootstrap/build/job.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,20 @@ pub unsafe fn setup() {
6464
mem::size_of_val(&info) as DWORD);
6565
assert!(r != 0, "{}", io::Error::last_os_error());
6666

67-
// Assign our process to this job object
67+
// Assign our process to this job object. Note that if this fails, one very
68+
// likely reason is that we are ourselves already in a job object! This can
69+
// happen on the build bots that we've got for Windows, or if just anyone
70+
// else is instrumenting the build. In this case we just bail out
71+
// immediately and assume that they take care of it.
72+
//
73+
// Also note that nested jobs (why this might fail) are supported in recent
74+
// versions of Windows, but the version of Windows that our bots are running
75+
// at least don't support nested job objects.
6876
let r = AssignProcessToJobObject(job, GetCurrentProcess());
69-
assert!(r != 0, "{}", io::Error::last_os_error());
77+
if r == 0 {
78+
CloseHandle(job);
79+
return
80+
}
7081

7182
// If we've got a parent process (e.g. the python script that called us)
7283
// then move ownership of this job object up to them. That way if the python

0 commit comments

Comments
 (0)