-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix race condition #1445
Fix race condition #1445
Conversation
… Don't raise error during update if temporary file has disappeared.
Hello again! Thank you for this new pull request 🤩. Don't forget to let me know when it is complete with the command Here is your checklist:
|
Unfortunately your PR is not passing the tests so it is not quite ready for review yet. Let me know when it is fixed with The failing tests are:
|
/bot run spelling docs |
Unfortunately your PR is not passing the tests so it is not quite ready for review yet. Let me know when it is fixed with The failing tests are:
|
Hey @pyccel/pyccel-dev ! @EmilyBourne has just created this great new pull request! Check it out and let me know what you think! |
/bot run pr_tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am so glad that you finally found the cause of the macOS failures!
The fix looks good and elegant to me. Great job!
I have a few minor comments.
@EmilyBourne, @yguclu has a few questions/comments about your code. Can you go through and see if you agree with them. If not go ahead and explain why. Once you've adressed all the comments let me know with |
/bot run docs |
The race condition is occurring on Macosx because Pyccel occasionally thinks that the source files in the stdlib folder have been modified. This then creates the following series of concurrent events:
ndarrays
folder lockndarrays
folderndarrays
folder lock. Waitingndarrays
folder lockndarrays.o
(ndarrays.o.lock
)ndarrays
folder lockndarrays
folder (may seendarrays.o.tmp
file created by compilation)__pyccel__/ndarrays
folder andstdlib/ndarrays
folder. Incorrectly determines folder needs updatingndarrays
folder (ndarrays.h.lock
,ndarrays.c.lock
,ndarrays.o.lock
)ndarrays.o
, (ndarrays.h
,ndarrays.c
)ndarrays
folderndarrays
folder contents back (onlyndarrays.h
,ndarrays.c
)ndarrays
locksndarrays
is necessaryndarrays.o
is missingndarrys.c.lock
The error is therefore not due to a race condition where 2 threads try to do the same thing, but rather due to a bad update condition. I think this is because we are checking when the files were accessed rather than when they were modified.
Additionally the compilation of
ndarrays.o
does not lockndarrays.c
. This is corrected in this PR but is not strictly necessary as thendarrays.o.lock
is always acquired ifndarrays.c.lock
is acquired.Commit Summary
CompileObj
a context manager (with methods__enter__
and__exit__
)with compile_obj:
constructs to handle locks more compactlyTesting
It is quite difficult to test this kind of error, however I have run the full suite of tests with
assert False
in the code which updates the std libraries and macosx no longer seems to go into this section of the code. (Linux triggers the assertion in the test designed to test this mechanism)