[Bug Report] Bug title Lifecycle and shutdown safety issues in base RL environments (ManagerBasedEnv & DirectRLEnv)
Description
While reviewing the base environment implementations, I noticed a set of lifecycle and shutdown-related issues that appear in both:
ManagerBasedEnv
DirectRLEnv
These issues are structurally similar and seem to originate from shared design patterns in the base environment logic.
This report groups them into a single master issue, as they affect multiple environment base classes in the same way.
Issue 1: Potential infinite loop during reset
Both environment implementations contain a loop of the form:
while SimulationManager.assets_loading(): self.sim.render()
There is:
no timeout
no iteration limit
no failure condition
Risk
If asset loading stalls or never completes (e.g. missing assets, driver issues, corrupted cache, or remote resource failure), the environment can enter a permanent infinite loop.
This leads to:
application hang
unrecoverable training process
resource exhaustion in headless or cluster environments
Impact
This is particularly problematic for:
distributed RL training
cloud or headless simulation
automated pipelines
Suggested fix
Add a timeout or maximum iteration guard, for example:
start_time = time.time() while SimulationManager.assets_loading(): self.sim.render() if time.time() - start_time > MAX_WAIT_SECONDS: raise RuntimeError("Asset loading timeout")
Issue 2: Non-deterministic cleanup via del
Both classes implement:
def del(self): self.close()
However, in Python:
del execution is not guaranteed
destruction order is undefined
it may run during interpreter shutdown
dependent objects may already be destroyed
Risk
The close() method:
manipulates simulation context
clears callbacks
destroys UI and physics resources
If del runs during interpreter teardown or after partial object destruction, this can cause:
crashes
segmentation faults
undefined behavior
resource leaks
Suggested fix
-
Remove or minimize logic inside del
-
Encourage explicit lifecycle management:
env = ManagerBasedEnv(cfg) try: ... finally: env.close()
Or implement a context manager:
class ManagerBasedEnv: def enter(self): return self
def __exit__(self, exc_type, exc, tb):
self.close()
Affected components
ManagerBasedEnv
DirectRLEnv
Both share similar lifecycle patterns and should likely be updated together.
Severity assessment
Issue Severity Impact
Infinite asset loading loop High Potential system hang / DoS in training Cleanup via del Medium Non-deterministic shutdown, possible crashes
Summary
These issues are not isolated bugs but stem from a shared lifecycle design pattern across environment base classes. A unified fix across both classes would likely improve robustness and reliability, especially in large-scale or headless training setups.
Thank you for your post. If there’s a human contact for this account, please feel free to reach out directly so we can discuss specifics by starting a New discussion in our Discussions section. I will close the issue for now. Thank you for your interest in Isaac Lab.