Sdk: Adding child processes to job objects prevents them from creating job objects of their own

Created on 8 Mar 2019  路  13Comments  路  Source: dotnet/sdk

We are hitting an issue while trying to test AspNetCore Module for IIS Express on Windows 7/2008R2 after taking and SDK with https://github.com/dotnet/cli/pull/10720 change.

In the test, we start IIS Express process that spawns new indstance of dotnet.exe, tries to attach it to a job object and fails because the entire process tree is already attached to the job object that CLI has created.

I see couple possible solutions:

  1. Disable process tracking using job objects on Windows 7
  2. Set JOB_OBJECT_LIMIT_BREAKAWAY_OK flag set on the job object.

cc @peterhuene @danmosemsft

Bug

All 13 comments

Which process are you attempting to add to a job object? IIS Express, dotnet, or the process spawned by dotnet?

I assume this is via a dotnet run?

We should probably be setting JOB_OBJECT_LIMIT_BREAKAWAY_OK anyway to better support Windows 7 (later versions support nesting jobs) so if a child process really is trying to break away, we allow it to do so.

Regardless, depending on what this test is expecting, that might not help this test's scenario.

Which process are you attempting to add to a job object

dotnet.exe spawned by IIS Express

I assume this is via a dotnet run?

dotnet test -> test assembly -> IIS Extpress -> CreateProcess(dotnet.exe)
                                   ^                             ^
                                 Owner of              Is added to IISExpress'es
                                new job object         job object

Regardless, depending on what this test is expecting, that might not help this test's scenario.

It wouldn't immediately help because we are not actively trying to break away but would at least allow us to do something to get the test working.

later versions support nesting jobs

I'm not able to find info about this anywhere

For reference: https://docs.microsoft.com/en-us/windows/desktop/procthread/nested-jobs

It says "Windows 7, Windows Server 2008 R2, Windows XP with SP3, Windows Server 2008, Windows Vista and Windows Server 2003: A process can be associated with only a single job. Nested jobs were introduced in Windows 8 and Windows Server 2012."

Right, versions later than 7 (i.e. 8+) support nested jobs.

Right, versions later than 7 (i.e. 8+) support nested jobs.

Sorry, I misread.

I'd hate to have to change how IIS express creates process to fix the test.

I think given Windows 7's impending EOL (9 months to go :tada:), limiting the job object usage in dotnet to 8+ would be acceptable.

I'll get that fix ready.

Thank you!

I've put up PR dotnet/cli#10949.

The fix to limit the job object usage to Windows 8+ is now in master, which is currently our preview 4 branch. The change will need to propagate through to dotnet/core-sdk before it is available in a build.

Was this page helpful?
0 / 5 - 0 ratings