coveragepy: SQLite Crash on Coverage 5.0a2 inside Hypothesis
I was running some unit tests using hypothesis (link) which relies on coverage, and I ran into a crash. Specifically, I received the following error message:
coverage.misc.CoverageException: Couldn't use data file '/Users/me/my_project/.coverage': UNIQUE constraint failed: file.path
I have experienced this issue both on macOS and Linux while running python 3.6, and the issue does not persist with COVERAGE_STORAGE=json
.
I have included a gist below which contains files to reproduce the error. Specifically, the error occurs when the hypothesis assume
statement in test.py
fails more than half the time and when wrap
is called.
To reproduce the error, run the build.sh
script, which will initialize a virtualenv, install required modules, and run a short example which should throw the error.
Additionally, I am including a vagrantfile which will run build.sh
in a VM, thus providing a clean slate for testing.
https://gist.github.com/TylerADavis/393ee6382b4f645774100ae0c490c5ba
Please let me know if there is any other information I could provide that would be useful.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (14 by maintainers)
Commits related to this issue
- CoverageSqliteData._file_id: fall back to SELECT Fixes https://github.com/nedbat/coveragepy/issues/702 — committed to blueyed/coveragepy by blueyed 6 years ago
- coveragerc: use parallel=true Works around https://github.com/nedbat/coveragepy/issues/702 with coveragepy 5.0a3. Failing build: https://circleci.com/gh/Vimjas/covimerage/1482 — committed to blueyed/covimerage by blueyed 6 years ago
- coveragerc: use parallel=true (#61) Works around https://github.com/nedbat/coveragepy/issues/702 with coveragepy 5.0a3. Failing build: https://circleci.com/gh/Vimjas/covimerage/1482 — committed to Vimjas/covimerage by blueyed 6 years ago
- CoverageSqliteData._file_id: fall back to SELECT Fixes https://github.com/nedbat/coveragepy/issues/702 — committed to blueyed/coveragepy by blueyed 6 years ago
I’ve bisected this to d2f77ab2ffc308e616af0207546ee1bef1cb8c75.
The problem appears to be that the file_map is only read when opening the DB, but another subprocess might have added the file later when the ID is needed.
https://github.com/nedbat/coveragepy/pull/723 fixes this for me.
My test case is https://github.com/Vimjas/covimerage/ (https://github.com/Vimjas/covimerage/commit/bb84cc9fbbc1750ce82c5add4d8f7d5a5429bef7), using
tox -e py37-coveragepy5-coverage -- -x
. (The initial failure is due to an autouse fixture, but also without this it fails, but later.)To be clear: I am seeing the problem @anarcat mentioned, and which might be different from the original issue, sorry.