dvsim sometimes erases the current directory
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13
- Forks
- 21
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
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: https://github.com/lowRISC/dvsim/commit/df68de6a4846d9b348508c88bfc629f8f7565a35
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how dvsim handles an empty cov_db_dir value and compare the behavior with commit df68de6a4846d9b348508c88bfc629f8f7565a35; reproduce the Verilator case described in the issue. Done means an empty value no longer targets . for deletion or causes the invalid-path exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100