From de2f28504a08b0490195f88df39f02ccfcc50b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Balv=C3=ADn?= Date: Wed, 7 Oct 2026 00:09:11 +0200 Subject: [PATCH] test(asm): parse once and assemble twice in the fuzz body Assisted-by: GLM 5.3 Flash --- asm/assembler_fuzz_test.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/asm/assembler_fuzz_test.go b/asm/assembler_fuzz_test.go index a5a8101..6aa46fa 100644 --- a/asm/assembler_fuzz_test.go +++ b/asm/assembler_fuzz_test.go @@ -105,15 +105,12 @@ func FuzzAssembleAMD64(f *testing.F) { } return } - // Determinism: a second parse-and-assemble from scratch must produce - // the same bytes, which also catches the assembler mutating the - // syntax tree it was handed. - file2, _ := parser.ParseWithOptions("fuzz_amd64.s", src, - parser.Options{Expand: true, IncludeDirs: fuzzIncludeDirs}) - if file2 == nil { - t.Fatal("the second ParseWithOptions returned a nil file") - } - img2, err2 := AssembleFile(file2) + // Determinism: a second assembly of the same file must produce the + // same bytes. One parse serves both runs, so any mutation the + // assembler makes to the syntax tree it was handed shows up as + // differing bytes, and the workers' footprint under the shared + // memory fence stays that of a single parse. + img2, err2 := AssembleFile(file) if err2 != nil { t.Fatalf("the second assembly failed where the first succeeded: %v", err2) }