diff --git a/src/main/java/com/code_intelligence/jazzer/instrumentor/TraceDataFlowInstrumentor.kt b/src/main/java/com/code_intelligence/jazzer/instrumentor/TraceDataFlowInstrumentor.kt index e637e9515..d4399c6a8 100644 --- a/src/main/java/com/code_intelligence/jazzer/instrumentor/TraceDataFlowInstrumentor.kt +++ b/src/main/java/com/code_intelligence/jazzer/instrumentor/TraceDataFlowInstrumentor.kt @@ -52,7 +52,7 @@ internal class TraceDataFlowInstrumentor( } } - val writer = ClassWriter(ClassWriter.COMPUTE_MAXS) + val writer = ClassWriter(reader, ClassWriter.COMPUTE_MAXS) node.accept(writer) return writer.toByteArray() } diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 7b4290d60..3626ff9ad 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -1077,6 +1077,37 @@ java_fuzz_target_test( ], ) +java_fuzz_target_test( + name = "NestedRecordFuzzer", + timeout = "short", + srcs = [ + "src/test/java/com/example/NestedRecordFuzzer.java", + ], + # This regression test checks if we instrument fuzz test classes with nested records correctly, + # and can start a fuzzing run at all without getting segfaults. + fuzzer_args = [ + "-print_final_stats=1", + "-runs=1", + ], + javacopts = [ + "--release", + "17", + ], + tags = [ + "no-jdk8", + ], + target_class = "com.example.NestedRecordFuzzer", + runtime_deps = [ + "@maven//:org_junit_jupiter_junit_jupiter_engine", + ], + deps = [ + "//deploy:jazzer-junit", + "//deploy:jazzer-project", + "@maven//:org_junit_jupiter_junit_jupiter_api", + "@maven//:org_junit_jupiter_junit_jupiter_params", + ], +) + java_fuzz_target_test( name = "BigDecimalFuzzer", srcs = [ diff --git a/tests/src/test/java/com/example/NestedRecordFuzzer.java b/tests/src/test/java/com/example/NestedRecordFuzzer.java new file mode 100644 index 000000000..f2da2ad62 --- /dev/null +++ b/tests/src/test/java/com/example/NestedRecordFuzzer.java @@ -0,0 +1,27 @@ +/* + * Copyright 2024 Code Intelligence GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example; + +import com.code_intelligence.jazzer.junit.FuzzTest; +import com.code_intelligence.jazzer.mutation.annotation.NotNull; + +public class NestedRecordFuzzer { + record Address(@NotNull String street, String city, String zipCode) {} + + @FuzzTest + public void test(Address ignored) {} +}