-
Notifications
You must be signed in to change notification settings - Fork 52
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
Parent objects get garbage collected before children' async operations finish which can lead to a crash #65
Comments
@Rush yeah, hmm memory is pretty tricky in these cases. There are a few ways to ensure the objects stick around (I think the persistent handle, as well as an explicit internal counter that can be increased), but then you need to ensure it's dereffed when it's no longer needed - big headaches here. Would it be possible to write a simple "manual" test case that we could run as part of the automated test suite? We could run that one with |
@Rush I'm running the following snippit:
and getting this output:
does that look like what you're running into? |
@Rush update here, that does look like the relevant error however I think we've tapped out my creativity on solving the problem 😄 I've spend about an hour trying to figure out how to "attach" the parent to the child object from the C++ side, but it seems incredibly difficult. I did, on the other hand, find a solution through javascript which might be the way to go (but then we've got a bit of work ahead of us) through this monkey-patch in
|
Consider this simplistic case case that can cause Segmentation fault:
Solution that fixes it is:
I am yet to devise a pure node-libvirt test case. Anyway, a way to test it is to try to create many volumes in parallel using the above pattern and preferably call node with
node --expose-gc
, furthermore add codeif(global.gc) setInterval(global.gc, 1);
which should make sure the GC kicks in.I think it may be somehow possible to increase the refcount in node-libvirt itself but it's hard for me to wrap my head around all those wrapper classes.
The text was updated successfully, but these errors were encountered: