Race condition when accessing library
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 430
- Forks
- 151
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 1
Description
Description
We create a temporary file that is a copy of the library when we instantiate a Library instance. This is necessary to avoid a bug in the software that prevents accessing multiple hardware peripherals in a single process. On rare occasions, dlopen will fail with an error along the lines of No Suitable Image found. It seems to best resemble this GRPC issue #5568. The solution seems to be forcing the file to be committed to disk through an atomic write.
Suggested Changes
- Use
fsyncafteros.writewhen creating aJLockobject. - Flush the
outputfilecreated inLibrary.loadafter write, then before closing the temporary file, callfsyncon it. - Add a test to catch this behaviour before the patch, then ensure it's fixed after the patch.
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 reading the code that creates a JLock object and the Library.load path that writes the temporary library file. Reproduce or add a test for the intermittent dlopen failure, then verify that the file is flushed and synchronized before it is closed and accessed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100