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

Reference counted ScipPtr #139

Closed
wants to merge 15 commits into from
Closed

Reference counted ScipPtr #139

wants to merge 15 commits into from

Conversation

mmghannam
Copy link
Member

@mmghannam mmghannam commented Apr 7, 2024

Fixes #138

@mmghannam
Copy link
Member Author

mmghannam commented Apr 7, 2024

@Nudelmeister turns out it was easy to do the change 😄 I would really appreciate a review here if you have the time :)

Update: there's a memory leak not sure why yet.

2nd Update: Fixed, was most probably because of thread unsafe counting of scip ptr references.

3rd Update: Was a false positive apparently :/

Copy link

codecov bot commented Apr 7, 2024

Codecov Report

Attention: Patch coverage is 95.65217% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 76.13%. Comparing base (b44bc33) to head (58fc879).

❗ Current head 58fc879 differs from pull request most recent head 3d5df58. Consider uploading reports for the commit 3d5df58 to get more accurate results

Files Patch % Lines
src/solution.rs 90.91% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #139      +/-   ##
==========================================
+ Coverage   76.02%   76.13%   +0.10%     
==========================================
  Files          13       13              
  Lines        1785     1797      +12     
==========================================
+ Hits         1357     1368      +11     
- Misses        428      429       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Nudelmeister
Copy link

This seems fine, though I thought of wrapping the whole ScipPtr struct in an Arc.
I can take a closer look tomorrow.

@Nudelmeister
Copy link

You could use a AtomicUsize instead of RwLock<usize>, but looking at how Arc is implemented it's more complicated than I thought.
Other than the general uneasiness of the large amounts of unsafe (I guess you can't really do anything about that), I'm happy with this fix.

Thanks for the quick response.

@mmghannam
Copy link
Member Author

You could use a AtomicUsize instead of RwLock<usize>, but looking at how Arc is implemented it's more
complicated than I thought. Other than the general uneasiness of the large amounts of unsafe (I guess you can't really do anything about that), I'm happy with this fix.

Thanks for the suggestion, I changed it :) There's still a memory leak, I will merge this once I figure out why and fix it.

Thanks for the quick response.

Thank you too for the quick review :)

@mmghannam mmghannam closed this Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

segfault (use after free) when accessing solution after model is dropped
2 participants