IsaacLab icon indicating copy to clipboard operation
IsaacLab copied to clipboard

[Bug Report] configure_logging leaves replaced root-logger handlers open (log file locked on Windows)

Open Sonica-B opened this issue 1 month ago • 0 comments

Describe the bug

isaaclab.utils.configure_logging (source/isaaclab/isaaclab/utils/logger.py) removes the root logger's existing handlers with root_logger.removeHandler(handler) but never calls handler.close(). A FileHandler installed by an earlier call keeps its log file open for the life of the process. On Windows that file cannot be deleted. On native Windows 11 this makes two unit tests fail:

  • source/isaaclab/test/utils/test_logger.py::test_configure_logging_with_file: TemporaryDirectory cleanup raises PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '...\custom_logs\isaaclab_*.log'
  • source/isaaclab/test/utils/test_logger.py::test_configure_logging_default_log_dir: os.remove(log_file_path) raises the same error.

Steps to reproduce

On Windows 11 at main 4a281f3 (Python 3.12, no Isaac Sim needed):

uv run python -m pytest source/isaaclab/test/utils/test_logger.py -q

On any OS, the leak is visible directly:

import logging, tempfile
from isaaclab.utils import configure_logging
d = tempfile.mkdtemp()
fh = configure_logging(save_logs_to_file=True, log_dir=d).handlers[1]
configure_logging(save_logs_to_file=False)
print(fh.stream)  # still an open file object; expected None after the handler is replaced

System Info

  • Commit: 4a281f3 (main)
  • Isaac Sim Version: not installed (not needed for this bug)
  • OS: Windows 11 Home 26200
  • GPU: not used (CPU-only PyTorch)
  • CUDA: not used
  • Python: 3.12.12, torch 2.11.0+cpu

Additional context

Proposed fix: close each removed handler (handler.close() after removeHandler), as logging.basicConfig(force=True) does, and have the two tests release their log file before cleanup. I have a branch with the fix and a regression assertion and am opening a PR for it.

Checklist

  • [x] I have checked that there is no similar issue in the repo (required)
  • [x] I have checked that the issue is not in running Isaac Sim itself and is related to the repo

Sonica-B avatar Oct 25 '26 09:10 Sonica-B