| Previous | Next |
| ERROR_EVENTLOG_FILE_CHANGED | ERROR_JOB_NO_CONTAINER |
ERROR_CONTAINER_ASSIGNED
A container is already assigned to the specified job object.
ERROR_CONTAINER_ASSIGNED is Win32 error 1504 (0x5E0). The value concerns a Windows job object that already carries container association state. Job objects group processes and enforce limits; container-aware subsystems can add isolation identity that is not equivalent to merely placing processes in an ordinary job. Reapplying setup to an already configured job is a lifecycle or ownership error, not a signal to create duplicate container state.
How duplicate assignment happens
- initialization runs twice after a partial retry or reentrant startup path
- two brokers believe they own container creation for the same job handle
- a cached named job is reopened from an earlier container instance
- cleanup closed one handle but did not destroy the underlying job and association
- state recovery does not distinguish create-new from attach-to-existing behavior
Lifecycle data to capture
Log the job handle origin, job name, process ID that created or opened it, container identifier, initialization generation, operation sequence, and all ownership transitions. Record whether the job was newly created or an existing named object was opened. Handle values alone are process-local and should be paired with stable object and container identities.
Diagnostic sequence
Trace job creation, container association, process assignment, and teardown as one transaction. Confirm whether CreateJobObject opened an existing named job by inspecting application state, not by assuming a non-null handle means a new object. Identify concurrent initializers and retry paths that can reach association after a previous success.
Query documented job information that is available to the application and verify which component owns the remaining handles. Container-specific state may be managed by higher-level Windows facilities rather than public job APIs, so retain the exact API or service that returned 1504 instead of guessing from the job object alone.
Correct response
If the existing association is the intended one, attach to or reuse the established container through the owning subsystem. Otherwise destroy the abandoned instance through its supported lifecycle and create a fresh job with a unique identity. Do not attempt to clear undocumented job state or ignore the error and continue with mismatched isolation assumptions.
Difference from process-to-job assignment
AssignProcessToJobObject associates a process with a job and has its own nesting and access rules. Error 1504 says the job itself already has container assignment. It should not be interpreted as merely “the process is already in a job.”
Example
A broker creates a named job, associates it with a container, then crashes before recording completion. On restart it opens the same job and reruns container setup, receiving 1504. Persisting the container identity and choosing an explicit attach path allows safe recovery without weakening isolation.
References
- Microsoft: System Error Codes (1300–1699)
- Microsoft: Job Objects
- Microsoft: QueryInformationJobObject
Looking for a different code? Search another status or error code.
