After instrumenting my code with SharpFuzz I get constant System.AccessViolationExceptions even without fuzzing.
I don't know what exactly causes it, but it seems to always happen in constructors.
I have prepared a tiny reproducer app.
Reproduce:
- Download the attached reproduce.tar.gz archive. It contains the source code for two projects: the
FuzzMe is an application under test and the FuzzMe.Fuzz is the fuzzing harness.
- Extract the archive:
tar zxvf reproduce.tar.gz
- [Review the code]
- Build the
FuzzMe.Fuzz app. No errors should pop up:
cd reproduce/tests/FuzzMe.Fuzz
dotnet publish -c Release --self-contained -r linux-x64
- Make sure the
FuzzMe.Fuzz app raises no exceptions:
echo test | ./bin/Release/net6.0/linux-x64/FuzzMe.Fuzz
- Instrument
FuzzMe* classes within the FuzzMe.dll with SharpFuzz:
export SHARPFUZZ_PRINT_INSTRUMENTED_TYPES=1
sharpfuzz ./bin/Release/net6.0/linux-x64/FuzzMe.dll FuzzMe
It should print:
FuzzMe.Parser
FuzzMe.Point
FuzzMe.Program
- Run the app again and observe the exception:
echo test | ./bin/Release/net6.0/linux-x64/FuzzMe.Fuzz
The output looks like this:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at FuzzMe.Point..ctor(Int32, Int32)
at FuzzMe.Fuzz.Program.Main(System.String[])
Aborted (core dumped)
The exit code is 134.
The SharpFuzz dependency is 2.0.1 and the SharpFuzz.CommandLine tool is also 2.0.1.
There are private/protected readonly fields in the constructors of Point and Parser classes, but changing them to public (and without readonly) changes nothing.
Is there some limitation in SharpFuzz regarding constructors? The real code I wish to test has lots of them.
After instrumenting my code with SharpFuzz I get constant
System.AccessViolationExceptions even without fuzzing.I don't know what exactly causes it, but it seems to always happen in constructors.
I have prepared a tiny reproducer app.
Reproduce:
FuzzMeis an application under test and theFuzzMe.Fuzzis the fuzzing harness.tar zxvf reproduce.tar.gzFuzzMe.Fuzzapp. No errors should pop up:cd reproduce/tests/FuzzMe.Fuzz dotnet publish -c Release --self-contained -r linux-x64FuzzMe.Fuzzapp raises no exceptions:FuzzMe*classes within theFuzzMe.dllwith SharpFuzz:export SHARPFUZZ_PRINT_INSTRUMENTED_TYPES=1 sharpfuzz ./bin/Release/net6.0/linux-x64/FuzzMe.dll FuzzMeIt should print:
The output looks like this:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at FuzzMe.Point..ctor(Int32, Int32) at FuzzMe.Fuzz.Program.Main(System.String[]) Aborted (core dumped)The exit code is 134.
The SharpFuzz dependency is 2.0.1 and the SharpFuzz.CommandLine tool is also 2.0.1.
There are
private/protectedreadonlyfields in the constructors of Point and Parser classes, but changing them topublic(and withoutreadonly) changes nothing.Is there some limitation in SharpFuzz regarding constructors? The real code I wish to test has lots of them.