A structure-aware fuzzer for the Gleam compiler generates randomized, type-safe Gleam programs, compiles and runs them for both Erlang and JavaScript, and compares their results to identify compiler defects. The implementation uses a simplified Gleam abstract syntax tree, called a “smith,” to compose valid expressions probabilistically. It normalizes differing runtime representations from Gleam’s echo output, including JavaScript’s printing of 1.0 as 1 and Erlang’s formatting of some bit arrays and record labels. The project first used Rust’s fuzzing tooling to send unstructured inputs through Gleam’s compiler pipeline in memory. That parser fuzzing found a nightly regression, absent from Gleam v1.18.1, in which a pipeline operator in a const expression caused a compiler panic. The type-safe program fuzzer has found nine issues so far, including JavaScript code-generation errors in pattern matching and variable shadowing, Erlang code-generation panics for unreachable branches, and an issue reported upstream to Erlang/OTP. One generated program produced 42 on Erlang and 103 on JavaScript for the same echoed value. The fuzzer currently covers only a subset of Gleam expressions and is run in manually reviewed batches of 100 programs. Proposed future work includes fuzzing generics, type inference, the language server, standard-library packages, metamorphic testing, automated deduplication, and integration into pull-request or release-candidate checks.
kurz.net
20 min
10h ago
A structure-aware fuzzer for the Gleam compiler generates randomized, type-safe Gleam programs, compiles and runs them for both Erlang and JavaScript, and compares their results to identify compiler defects. The implementation uses a simplified Gleam abstract syntax tree, called a “smith,” to compose valid expressions probabilistically. It normalizes differing runtime representations from Gleam’s echo output, including JavaScript’s printing of 1.0 as 1 and Erlang’s formatting of some bit arrays and record labels. The project first used Rust’s fuzzing tooling to send unstructured inputs through Gleam’s compiler pipeline in memory. That parser fuzzing found a nightly regression, absent from Gleam v1.18.1, in which a pipeline operator in a const expression caused a compiler panic. The type-safe program fuzzer has found nine issues so far, including JavaScript code-generation errors in pattern matching and variable shadowing, Erlang code-generation panics for unreachable branches, and an issue reported upstream to Erlang/OTP. One generated program produced 42 on Erlang and 103 on JavaScript for the same echoed value. The fuzzer currently covers only a subset of Gleam expressions and is run in manually reviewed batches of 100 programs. Proposed future work includes fuzzing generics, type inference, the language server, standard-library packages, metamorphic testing, automated deduplication, and integration into pull-request or release-candidate checks.
kurz.net
20 min
10h ago
A structure-aware fuzzer for the Gleam compiler generates randomized, type-safe Gleam programs, compiles and runs them for both Erlang and JavaScript, and compares their results to identify compiler defects. The implementation uses a simplified Gleam abstract syntax tree, called a “smith,” to compose valid expressions probabilistically. It normalizes differing runtime representations from Gleam’s echo output, including JavaScript’s printing of 1.0 as 1 and Erlang’s formatting of some bit arrays and record labels. The project first used Rust’s fuzzing tooling to send unstructured inputs through Gleam’s compiler pipeline in memory. That parser fuzzing found a nightly regression, absent from Gleam v1.18.1, in which a pipeline operator in a const expression caused a compiler panic. The type-safe program fuzzer has found nine issues so far, including JavaScript code-generation errors in pattern matching and variable shadowing, Erlang code-generation panics for unreachable branches, and an issue reported upstream to Erlang/OTP. One generated program produced 42 on Erlang and 103 on JavaScript for the same echoed value. The fuzzer currently covers only a subset of Gleam expressions and is run in manually reviewed batches of 100 programs. Proposed future work includes fuzzing generics, type inference, the language server, standard-library packages, metamorphic testing, automated deduplication, and integration into pull-request or release-candidate checks.
kurz.net
20 min
10h ago
No more articles to load