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

Fix refcount calculation when copying data to heaps #1498

Merged
merged 2 commits into from
Feb 15, 2025

Conversation

pguyot
Copy link
Collaborator

@pguyot pguyot commented Jan 26, 2025

Ref count should be incremented whenever the ref counted binary is added to
the mso list and decremented when the mso list is swept.

Also refc_binaries are allocated with a ref count of 0 until they are made
a term, with the exception of enif_alloc_resource that should be balanced
by an enif_release_resource following OTP semantic.

Also add a new test for heap operations including gc.

Also fix race conditions with demonitor in both otp_socket and emscripten
code that yielded a crash by over decrementing ref count.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

@pguyot pguyot force-pushed the w04/fix-refcount-calculation branch 3 times, most recently from 86a76ec to 7903237 Compare January 28, 2025 06:45
@pguyot pguyot force-pushed the w04/fix-refcount-calculation branch from 7903237 to 02e2e87 Compare February 10, 2025 21:45
@pguyot pguyot force-pushed the w04/fix-refcount-calculation branch 5 times, most recently from 4e2c18c to e8306bc Compare February 14, 2025 22:46
Ref count should be incremented whenever the ref counted binary is added to
the mso list and decremented when the mso list is swept.

Also refc_binaries are allocated with a ref count of 0 until they are made
a term, with the exception of enif_alloc_resource that should be balanced
by an enif_release_resource following OTP semantic.

Also add a new test for heap operations including gc.

Also fix race conditions with demonitor in both otp_socket and emscripten
code that yielded a crash by over decrementing ref count.

Signed-off-by: Paul Guyot <pguyot@kallisys.net>
@pguyot pguyot force-pushed the w04/fix-refcount-calculation branch from e8306bc to 77cfcbb Compare February 14, 2025 22:49
@pguyot pguyot marked this pull request as ready for review February 14, 2025 22:51
@bettio bettio merged commit ed97478 into atomvm:release-0.6 Feb 15, 2025
102 checks passed
@pguyot pguyot deleted the w04/fix-refcount-calculation branch February 15, 2025 09:59
bettio added a commit that referenced this pull request Feb 15, 2025
Merge a number of fixes from release-0.6 into main.
Most importantly: fix refcount calculation when copying data to heaps #1498.
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.

2 participants