Skip to content

Conversation

@bettio
Copy link
Collaborator

@bettio bettio commented Feb 11, 2026

memory_ensure_free_with_roots(..., 2, (term[]){ key, value }, ...) is a bad pattern.
In this example, after GC, roots should be read since key and value now may point to invalid terms, but that anonymous array cannot be accessed, so actual key and value cannot be read.

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

Copy link
Collaborator

@pguyot pguyot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format needs to be made happy but otherwise it's great.
Also I wouldn't call it a "potential" bug, it's just a bug.

@bettio bettio changed the title NIFs: fix potential bug in erlang:fun_info/2 NIFs: fix bug in erlang:fun_info/2 Feb 11, 2026
`memory_ensure_free_with_roots(..., 2, (term[]){ key, value }, ...)` is
a bad pattern.
In this example, after GC, roots should be read since `key` and `value` now
may point to invalid terms, but that anonymous array cannot be accessed,
so actual `key` and `value` cannot be read.

Signed-off-by: Davide Bettio <davide@uninstall.it>
@bettio bettio force-pushed the fix-erlang-fun_info-bug branch from c22334f to 292e1d8 Compare February 12, 2026 08:35
@bettio bettio merged commit d591106 into atomvm:main Feb 12, 2026
141 of 144 checks passed
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