-
Notifications
You must be signed in to change notification settings - Fork 261
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
Memory leak: fix the cyclic-ness of the DAG #1010
Comments
Only a compacting GC would do that, right? |
Nim GC does relocate refs and I was bitten by it: I tried this: nim-lang/Nim#9974 but in the end it led to very hard to investigate bugs in my DAG and I had to remove The worse is that when the ref was moved, it was replaced not by uninitialized or invalid memory that would crash but by another valid ref. To detect that I had to print my DAG link and then i realize that I was somehow not jumping from child to parent but there were missing links. |
don't sweat it: #669 |
Just remove the |
indeed. |
The DAG has cycles on
BlockRef
but it is tagged{.acyclic.}
.With the default refcounting GC, it's a guaranteed memory leak as
acyclic
means "trust me, you don't need to run cycle detection" to the GC.https://github.com/status-im/nim-beacon-chain/blob/9636ca3e17628d4bfbdc2a29006e5385fc398e66/beacon_chain/beacon_node_types.nim#L158-L172
Either we lose the {.acyclic.} tag (which means BlockRef alloc/dealloc will trigger both refcounting and mark-and-sweep). Or we remove either the parent field or the children field.
Using pointers for weak ref is not possible as the GC can relocate ref objects in memory and invalidate the pointer and
{.cursor.}
is for GC:ARC.The text was updated successfully, but these errors were encountered: