Nightly-multi-test valgrind fix#10190
Merged
douzzer merged 1 commit intowolfSSL:masterfrom Apr 11, 2026
Merged
Conversation
douzzer
approved these changes
Apr 11, 2026
Contributor
douzzer
left a comment
There was a problem hiding this comment.
Good fix, thanks @rlm2002 !
Before fix:
valgrind --leak-check=full unit.test...==4214== Invalid read of size 16
25b2c664f4 wolfcrypt/src/wc_kyber_asm.S (<sean@wolfssl.com> 2024-03-12 09:43:26 +1000 12626) vmovdqu (%rdx), %xmm0
==4214== at 0x4E78742: mlkem_rej_uniform_n_avx2 (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem_asm.S:12626)
==4214== by 0x1FFEFFDC8F: ???
==4214== by 0x663FA0F: ???
==4214== by 0xFF: ???
==4214== by 0xFF: ???
==4214== by 0xFF: ???
==4214== by 0xFF: ???
a7690ca24b (<sean@wolfssl.com> 2025-03-06 14:19:00 +1000 2619) ctr3 = mlkem_rej_uniform_n_avx2(a + 3 * MLKEM_N, MLKEM_N, p,
==4214== by 0x4E68F9E: mlkem_gen_matrix_k4_avx2 (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem_poly.c:2619)
a7690ca24b (<sean@wolfssl.com> 2025-03-06 14:19:00 +1000 3579) ret = mlkem_gen_matrix_k4_avx2(a, seed, transposed);
==4214== by 0x4E68F9E: mlkem_gen_matrix (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem_poly.c:3579)
==4214== by 0x7B3CD28132D18804: ???
==4214== by 0x51C077BB56A50523: ???
==4214== by 0xA47CD716A8536862: ???
==4214== by 0x91222D499DA7131A: ???
==4214== Address 0x684c6c4 is 2,004 bytes inside a block of size 2,018 alloc'd
==4214== at 0x4C94858: malloc (/tmp/portage/dev-debug/valgrind-3.26.0_p1/work/valgrind-3.26.0/coregrind/m_replacemalloc/vg_replace_malloc.c:447)
401868908a (<douzzer@wolfssl.com> 2025-05-15 15:28:11 -0500 2572) rand = (byte*)XMALLOC(4 * GEN_MATRIX_SIZE + 2, NULL,
==4214== by 0x4E68A03: mlkem_gen_matrix_k4_avx2 (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem_poly.c:2572)
a7690ca24b (<sean@wolfssl.com> 2025-03-06 14:19:00 +1000 3579) ret = mlkem_gen_matrix_k4_avx2(a, seed, transposed);
==4214== by 0x4E68A03: mlkem_gen_matrix (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem_poly.c:3579)
3b4e51c150 (<tobias@wolfssl.com> 2026-02-10 19:07:15 +0100 992) ret = mlkem_gen_matrix(&key->prf, a, (int)k, key->pubSeed, 1);
==4214== by 0x4E61AEE: mlkemkey_encapsulate (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem.c:992)
a7690ca24b (<sean@wolfssl.com> 2025-03-06 14:19:00 +1000 1329) ret = mlkemkey_encapsulate(key, msg, kr + WC_ML_KEM_SYM_SZ, c);
==4214== by 0x4E62D71: wc_MlKemKey_EncapsulateWithRandom (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem.c:1329)
5c497c62e7 (<douzzer@wolfssl.com> 2024-05-23 00:15:32 -0500 47138) ret = wc_KyberKey_EncapsulateWithRandom(key, ct, ss, kyber1024enc_rand,
==4214== by 0x4162F07: mlkem1024_kat (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/test/test.c:47138)
a7690ca24b (<sean@wolfssl.com> 2025-03-06 14:19:00 +1000 47506) ret = mlkem1024_kat();
==4214== by 0x4162F07: mlkem_test (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/test/test.c:47506)
a7690ca24b (<sean@wolfssl.com> 2025-03-06 14:19:00 +1000 2801) if ( (ret = mlkem_test()) != 0)
==4214== by 0x416A168: wolfcrypt_test (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/test/test.c:2801)
9a84dfc86a (<douzzer@wolfssl.com> 2025-03-11 14:59:07 -0500 264) wolfcrypt_test(&wc_args);
==4214== by 0x405A29E: unit_test (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/tests/unit.c:264)
f643ca5f48 (<vikram.adiga@ti.com> 2014-05-08 15:52:20 -0700 70) int unit_test(int argc, char** argv)
==4214== by 0x405A29E: unit_test (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/tests/unit.c:70)
==4214== by 0x5534253: (below main) (/usr/src/debug/sys-libs/glibc-2.43/glibc-2.43/csu/../sysdeps/nptl/libc_start_call_main.h:59)
==4214==
==4214== Invalid read of size 16
25b2c664f4 wolfcrypt/src/wc_kyber_asm.S (<sean@wolfssl.com> 2024-03-12 09:43:26 +1000 12626) vmovdqu (%rdx), %xmm0
==4214== at 0x4E78742: mlkem_rej_uniform_n_avx2 (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem_asm.S:12626)
==4214== by 0x1FFEFFD66F: ???
==4214== by 0x672C46F: ???
==4214== by 0xFF: ???
==4214== by 0xFF: ???
==4214== by 0xFF: ???
==4214== by 0xFF: ???
a7690ca24b (<sean@wolfssl.com> 2025-03-06 14:19:00 +1000 2619) ctr3 = mlkem_rej_uniform_n_avx2(a + 3 * MLKEM_N, MLKEM_N, p,
==4214== by 0x4E68F9E: mlkem_gen_matrix_k4_avx2 (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem_poly.c:2619)
a7690ca24b (<sean@wolfssl.com> 2025-03-06 14:19:00 +1000 3579) ret = mlkem_gen_matrix_k4_avx2(a, seed, transposed);
==4214== by 0x4E68F9E: mlkem_gen_matrix (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem_poly.c:3579)
==4214== by 0x7B3CD28132D18804: ???
==4214== by 0x51C077BB56A50523: ???
==4214== by 0xA47CD716A8536862: ???
==4214== by 0x91222D499DA7131A: ???
==4214== Address 0x6643264 is 2,004 bytes inside a block of size 2,018 alloc'd
==4214== at 0x4C94858: malloc (/tmp/portage/dev-debug/valgrind-3.26.0_p1/work/valgrind-3.26.0/coregrind/m_replacemalloc/vg_replace_malloc.c:447)
401868908a (<douzzer@wolfssl.com> 2025-05-15 15:28:11 -0500 2572) rand = (byte*)XMALLOC(4 * GEN_MATRIX_SIZE + 2, NULL,
==4214== by 0x4E68A03: mlkem_gen_matrix_k4_avx2 (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem_poly.c:2572)
a7690ca24b (<sean@wolfssl.com> 2025-03-06 14:19:00 +1000 3579) ret = mlkem_gen_matrix_k4_avx2(a, seed, transposed);
==4214== by 0x4E68A03: mlkem_gen_matrix (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem_poly.c:3579)
3b4e51c150 (<tobias@wolfssl.com> 2026-02-10 19:07:15 +0100 992) ret = mlkem_gen_matrix(&key->prf, a, (int)k, key->pubSeed, 1);
==4214== by 0x4E61AEE: mlkemkey_encapsulate (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem.c:992)
a7690ca24b (<sean@wolfssl.com> 2025-03-06 14:19:00 +1000 1683) ret = mlkemkey_encapsulate(key, msg, kr + WC_ML_KEM_SYM_SZ, cmp);
==4214== by 0x4E63070: wc_MlKemKey_Decapsulate (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/src/wc_mlkem.c:1683)
82b50f19c6 (<sean@wolfssl.com> 2025-02-18 18:51:14 +1000 47153) ret = wc_KyberKey_Decapsulate(key, ss_dec, kyber1024_ct,
==4214== by 0x4162F74: mlkem1024_kat (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/test/test.c:47153)
a7690ca24b (<sean@wolfssl.com> 2025-03-06 14:19:00 +1000 47506) ret = mlkem1024_kat();
==4214== by 0x4162F74: mlkem_test (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/test/test.c:47506)
a7690ca24b (<sean@wolfssl.com> 2025-03-06 14:19:00 +1000 2801) if ( (ret = mlkem_test()) != 0)
==4214== by 0x416A168: wolfcrypt_test (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/wolfcrypt/test/test.c:2801)
9a84dfc86a (<douzzer@wolfssl.com> 2025-03-11 14:59:07 -0500 264) wolfcrypt_test(&wc_args);
==4214== by 0x405A29E: unit_test (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/tests/unit.c:264)
f643ca5f48 (<vikram.adiga@ti.com> 2014-05-08 15:52:20 -0700 70) int unit_test(int argc, char** argv)
==4214== by 0x405A29E: unit_test (/tmp/tmp.4346_28411/wolfssl_test_workdir.35209/wolfssl/tests/unit.c:70)
==4214== by 0x5534253: (below main) (/usr/src/debug/sys-libs/glibc-2.43/glibc-2.43/csu/../sysdeps/nptl/libc_start_call_main.h:59)
==4214==
After fix:
valgrind --leak-check=full unit.test... real 21m12.150s user 21m4.123s sys 0m0.387s
scenario started 2026-04-11T17:41:54.083974Z, real elapsed 22m19.210478s
(Yes it really takes 22m on a Threadripper 7960X...)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Increase rand buffer, fix valgrind invalid read size 16
Testing