Skip to content
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

Nested imports cause deadlock #7

Closed
lokuz opened this issue Mar 29, 2016 · 4 comments
Closed

Nested imports cause deadlock #7

lokuz opened this issue Mar 29, 2016 · 4 comments

Comments

@lokuz
Copy link

lokuz commented Mar 29, 2016

Nested imports cause deadlocks. The deadlock is caused by native libraries which are loading (indirectly) other native libraries before calling "LEAVE_JyNI". Then the next JyNI_loadModule (JyNI.c) call will stop at ENTER_JyNI.

One possible solution might be to add LEAVE_JyNI and ENTER_JyNI around the call of the dynamic load function (return value of _PyImport_GetDynLoadFunc) in _PyImport_LoadDynamicModuleJy (importdl.c) i.e. around line (*p)();

Another solution might be to check in loadModule in JyNI.java, if one was called from the native library and then calls LEAVE_JyNI and at the end of the function restores the state by calling ENTER_JyNI.

Stefan, I would be happy to hear your opinion on that, since I do not know what requirements on this locking mechanism exist.

@Stewori
Copy link
Owner

Stewori commented Mar 29, 2016

Probably using RE_ENTER_JyNI and RE_LEAVE_JyNI instead of ENTER_JyNI and LEAVE_JyNI would fix this. I am actually about to replace ENTER_JyNI and LEAVE_JyNI by RE_ENTER_JyNI and RE_LEAVE_JyNI at all; they were made before redesign of thread state handling in JyNI alpha 3.
So far I was not confident enough about this decision yet and only replaced where needed. You can try to apply this in JyNI_loadModule. RE_ENTER_JyNI and RE_LEAVE_JyNI lock per thread state and not per call, so entering JyNI using the same thread state preserves the lock.

@lokuz
Copy link
Author

lokuz commented Mar 30, 2016

Thanks for your recommendation. I will try this.

@Stewori
Copy link
Owner

Stewori commented Apr 13, 2016

Can you provide a minimal code sample that triggered this issue for you?

@Stewori
Copy link
Owner

Stewori commented Apr 14, 2016

So, I already ran into this issue myself while investigating umath module.
Should be fixed as of 66a74e0

@Stewori Stewori closed this as completed Apr 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants