Skip to content

fuzz-tests: improve fuzz-bigsize#8301

Merged
rustyrussell merged 3 commits intoElementsProject:masterfrom
Chand-ra:fuzz-bigsize
Sep 15, 2025
Merged

fuzz-tests: improve fuzz-bigsize#8301
rustyrussell merged 3 commits intoElementsProject:masterfrom
Chand-ra:fuzz-bigsize

Conversation

@Chand-ra
Copy link

@Chand-ra Chand-ra commented May 20, 2025

Add a couple of improvements to the fuzz test for bigsize_t operations-tests/fuzz/fuzz-bigsize. Commit the newly discovered seed corpus inputs as well.

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.

CC: @morehouse

for (size_t i = 0; i < tal_count(wire_chunks); i++) {
wire_max = tal_count(wire_chunks[i]);
wire_ptr = wire_chunks[i];
for (size_t max = 0; max <= BIGSIZE_MAX_LEN; max++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max is unused, so what is the purpose of looping BIGSIZE_MAX_LEN times?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, it should've been:

wire_chunks = get_chunks(NULL, data, size, max);

instead of:

wire_chunks = get_chunks(NULL, data, size, 8);

Changelog-None: The exisiting fuzz test only extracts chunks of
a fixed size (8) from the fuzzer's input. Replace this with an
iteration over a set of chunk sizes (1 to BIGSIZE_MAX_LEN) for
better coverage.

While at it, get rid of the check `if (bs != 0)` because 0 is a
valid value for bigsize_t as well.
Copy link
Contributor

@morehouse morehouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I'd prefer to simplify by removing the chunking entirely and setting an input max len of 8, that would completely change the existing corpus. Could still be done in the future.

Comment on lines +17 to +18
for (size_t max = 1; max <= BIGSIZE_MAX_LEN; max++) {
wire_chunks = get_chunks(NULL, data, size, max);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: chunk_size would be a more descriptive name

Suggested change
for (size_t max = 1; max <= BIGSIZE_MAX_LEN; max++) {
wire_chunks = get_chunks(NULL, data, size, max);
for (size_t chunk_size = 1; chunk_size <= BIGSIZE_MAX_LEN; chunk_size++) {
wire_chunks = get_chunks(NULL, data, size, chunk_size);

Chandra Pratap added 2 commits June 9, 2025 06:01
Add a roundtrip check for `bigsize_put()` using `bigsize_get()`.
This enforces a stricter check for the former and adds a test
for the latter, which is currently untested.
Improvements in the fuzz-testing scheme of fuzz-bigsize led
to the discovery of test inputs that result in greater in
code-coverage. Add these inputs to the test's seed corpus.
Copy link
Contributor

@morehouse morehouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6effb40

@rustyrussell rustyrussell merged commit 3e96f07 into ElementsProject:master Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants