IsaacLab icon indicating copy to clipboard operation
IsaacLab copied to clipboard

[Bug Report] Bug title Lifecycle and shutdown safety issues in base RL environments (ManagerBasedEnv & DirectRLEnv)

Open red1239109-cmd opened this issue 9 months ago • 1 comments

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

  1. Remove or minimize logic inside del

  2. 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.

red1239109-cmd avatar Feb 16 '26 17:02 red1239109-cmd

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.

RandomOakForest avatar Feb 17 '26 13:02 RandomOakForest