Skip to content

dvsim sometimes erases the current directory #226

@Timmmm

Description

@Timmmm

If cov_db_dir is empty (which it is for Verilator), then dvsim will both crash with an exception about . not being a valid path, and it will recursively delete the current directory. That really is what Python does by default. Mental.

~/d1$ touch foo
~/d1$ python3
Python 3.13.7 (main, Mar  3 2026, 12:19:54) [GCC 15.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Ctrl click to launch VS Code Native REPL
>>> from pathlib import Path
>>> import shutil
>>> shutil.rmtree(Path(""))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    import platform
  File "/usr/lib/python3.13/shutil.py", line 763, in rmtree
    _rmtree_safe_fd(stack, onexc)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/shutil.py", line 707, in _rmtree_safe_fd
    onexc(func, path, err)
    ~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/shutil.py", line 658, in _rmtree_safe_fd
    os.rmdir(name, dir_fd=dirfd)
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 22] Invalid argument: PosixPath('.')
>>> 
~/d1$ ls
~/d1$ 

And yeah Path("").exists() is True! I'm struggling to think why that makes any sense.

Anyway fix here, I think. It may not be complete but it works for me: df68de6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions