Commit Graph
8 Commits
Author SHA1 Message Date
Kacper Michajłow cc660f8609 fuzzers: set fontconfig sysroot
Allows to specify custom fontconfig sysroot. Useful for fuzzing
environments where we might use specific config, font or the system wide
config is not available.
2025-08-06 03:14:58 +02:00
Kacper Michajłow 88f34229c6 fuzzers/common: stop after 15 events if there is not playback reset
We wait for timeout and stop fuzzing, but if there are events spammed
this timeout never fire, so instead limit the number of events after
playback reset.
2025-07-12 01:57:43 +02:00
Kacper Michajłow 5f927c6333 fuzzers: limit input size to 100KiB
While testing larger inputs can be useful for uncovering bugs related to
processing large data or inefficiencies in memory allocation, it also
makes the fuzzing process slower and more fragile.

Beyond the obvious slowdown, there are OOM issues and even in libFuzzer.
Specifically, in fuzzer::InputCorpus::AddToCorpus, after a few hours of
fuzzing, we accumulate so many inputs that memory usage exceeds our
quota. This could be mitigated in other ways, such as dumping data early
or shortening the fuzzing run duration. However, in practice, these huge
inputs are often not very useful.

This change will also encourage the fuzzer to mutate existing data
rather than continually adding more bytes to input, because it give
higher coverage. Which in turn will produce higher quality corpus.

The 100 KiB limit could be reduced further. It's still quite large, let's
see how it performs. I believe even 10 KiB might be sufficient or less.

This issue is especially noticeable in the Matroska fuzzer, because we
add input data there, which is bigger and sets max_len high in fuzzer
itself.

In a perfect world, we wouldn't need to impose such limits, but in
reality, we face constraints in both memory and compute resources.

I'll monitor coverage and fuzzing results after this change and adjust
as needed. Unfortunately, this will discard all existing corpus entries
larger than the limit, but that's expected.
2025-07-05 16:35:00 +02:00
Kacper Michajłow d759e26fd0 libmpv: use correct header directory name
libmpv headers are installed to `mpv/`, so why are we pretending it is
`libmpv`?

Fixes documentation, libmpv meson dependency, tests.
2025-02-23 01:40:12 +01:00
Kacper Michajłow 938938a985 fuzzer_options_parser: add options parser fuzzing
To improve coverage of parse_commandline.c
2024-08-27 01:31:40 +02:00
Kacper Michajłow ed77616f29 fuzzer: stop player after 5 seconds of playback
Timeouts can happen with various conditions, big, slow to decode files
is one of them. Most of the time those timeouts are not really important
to "fix". While they may show some issues like we currently have with
audio EOF #14427 for ao-null-untimed. Most of the reports are completely
not important and we should focus on other topics.

Ignore the timeouts during file playback, note that this will still
report any timeouts that happen in other conditions.

5 seconds of playback should cover most of interesting mpv code, even
for strange samples.

This will likely be reverted at some point in the future, but let first
stabilize the OSS-Fuzz, without dozens of bogus timeouts.
2024-07-17 22:17:52 +02:00
Kacper Michajłow fc0d0f10eb fuzzers/common: add prototype for LLVMFuzzerTestOneInput
To suppress warning.
2024-06-05 19:07:58 +02:00
Kacper Michajłow 47dbc3a74e fuzzers: add new fuzzer targets
fuzzer_set_property.c:

fuzz mpv_set_property in both initialized and non-initialized state.
Useful for user provided values sanitization test. I've already seen
some memory leaks in parsing code, good to drill it.

fuzzer_loadfile.c:

mpv_command "loadfile" test. Good for testing demuxers, decoding and
playback loop. Sadly in headless mode we can't really test AO and VO,
but at least all the code around can be fuzzed. Especially our custom
demuxers like demux_mkv.

fuzzer_loadfile_direct.c:

Similar to loadfile above, but instead of saving the data to file, it
passes the fuzz input in the command. Generated protocol specific
versions (mf:// and memory:// for now) and generic one.

Nothing really complex, but good start and even those few targets should
give good coverage of the most common code paths in libmpv.
2024-04-27 02:47:47 +02:00