Fix term_is_uint32 bigint handling on 32-bit#2380
Conversation
term_is_uint32 was returning true on 32-bit builds for big integers whose low 64 bits fit uint32_t, so term_to_uint32 truncated them. Signed-off-by: Davide Bettio <davide@uninstall.it>
Check the term_is_* integer predicates and term_to_* conversions against per-case expected flags, and run the new test-term binary in CI. Signed-off-by: Davide Bettio <davide@uninstall.it>
8bc1a69 to
6c321aa
Compare
Review of
|
On 32-bit builds term_is_uint32 returned true for big integers whose
low 64 bits fit uint32_t, so term_to_uint32 silently truncated them:
erlang:crc32/2, erlang:crc32_combine/3 and crypto:pbkdf2_hmac/5
computed with truncated values instead of raising badarg. 64-bit
builds are unaffected.
Reject boxed integers larger than BOXED_TERMS_REQUIRED_FOR_INT64
terms, so big integers fall through to false, and add big integer
regression cases to the crc32 Erlang test.
Also introduce test-term, a C unit test covering the term.h integer
predicates and conversions against per-case expected flags; it runs
in CI on all platforms, including the emulated 32-bit targets.
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