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

Orphan blocks are leaked on flush #261

Closed
denravonska opened this issue Apr 3, 2017 · 8 comments
Closed

Orphan blocks are leaked on flush #261

denravonska opened this issue Apr 3, 2017 · 8 comments
Assignees
Labels
Milestone

Comments

@denravonska
Copy link
Member

The blocks which are not yet a part of the chain are considered orphan and stored in mapOrphanBlocks which is periodically flushed during sync. The problem is that it's storing naked pointers which aren't deleted on flush which should cause a memory leak (haven't checked in Valgrind yet).

Change this to store a shared pointer until the block has been serialized to disk and detached from the orphan map.

@denravonska denravonska added the bug label Apr 3, 2017
@denravonska denravonska self-assigned this Apr 3, 2017
@denravonska
Copy link
Member Author

@tomasbrod @skcin I'm torn between the following fixes:

  • shared_ptr: Correct and safe implementation but the change is larger and sticks out like a sore thumb compared to all the raw pointers in the system.
  • raw ptr: Matches current implementation, small and isolated fix but still using unsafe raw pointers.

Thoughts?

@grctest
Copy link
Contributor

grctest commented Apr 20, 2017

but the change is larger and sticks out like a sore thumb compared to all the raw pointers in the system.

Would this introduce instability?

@denravonska
Copy link
Member Author

denravonska commented Apr 20, 2017

@grctest I'd say no and that we want to move towards shared_ptr anyway, but implementing it in just one spot makes that particular spot not behave the way you have come to know or expect. For example:

void getValue1(string name, string& value)
void getValue2(string name, string& value)
void getValue3(string name, string& value)

Hypothetical refactoring of getValue3 into:

string getValue3(const string& name)

makes it correct but now it's inconsistent with the other two. It's pretty much the same here :)

I'm leaning towards making the small implementation now and doing a more broad switch to shared_ptr "in the future".

@denravonska denravonska added this to the Unnamed milestone Aug 25, 2017
@tomasbrod
Copy link
Member

This is still issue.

@pwnorbitals
Copy link
Contributor

pwnorbitals commented Sep 8, 2017

Submitted a pull request with a quick fix.
I'm just getting started with Github so I messed up with the first commit which included more than it should have. I think I successfully removed it.

@iFoggz
Copy link
Member

iFoggz commented Sep 9, 2017

#261

@pwnorbitals
Copy link
Contributor

#609

@denravonska
Copy link
Member Author

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants