Bug 514059 - Segmentation fault in get_bszB_as_is after program performs an invalid write
Summary: Segmentation fault in get_bszB_as_is after program performs an invalid write
Status: RESOLVED NOT A BUG
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (other bugs)
Version First Reported In: 3.25.1
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-01-01 23:08 UTC by julian
Modified: 2026-01-05 06:56 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
The program under test, its sources, the test file, the log file and the combined coredump (3.20 MB, application/zip)
2026-01-01 23:08 UTC, julian
Details

Note You need to log in before you can comment on or make changes to this bug.
Description julian 2026-01-01 23:08:34 UTC
Created attachment 188144 [details]
The program under test, its sources, the test file, the log file and the combined coredump

SUMMARY
Valgrind crashes while checking a program (a C compiler) that is known to be faulty.

STEPS TO REPRODUCE
1. Decompress the provided attachment
2. Run `valgrind ./build/main/lilycc test-files/test_compound.c`

OBSERVED RESULT
Valgrind detects an invalid read and an invalid write, then receives a segmentation fault in its own code.

EXPECTED RESULT
Valgrind itself should not have received the segmentation fault.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.5.4
KDE Frameworks Version: 6.21.0
Qt Version: 6.10.1
Kernel Version: 6.12.62-1-lts (64-bit)
Graphics Platform: Wayland
Processors: 8 × 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz
Memory: 40 GiB of RAM (39.0 GiB usable)
Graphics Processor: Intel® Iris® Xe Graphics

ADDITIONAL INFORMATION
The program in question can also be found at https://github.com/robotman2412/lily-cc however there are uncommitted changes in my working tree (thus the sources included in the attachment).
Comment 1 Paul Floyd 2026-01-05 06:56:42 UTC
Memcheck has detected a bug in your code. After that, especially invalid writes, anything can happen. We do not make any promises that Valgrind will be able to continue in a correct manner. The same is true for all dynamic analysis tools as far as I know.

What you can do is increase the redzone size, e.g., 

valgrind --redzone-size=128 ./build/main/lilycc test-files/test_compound.c

That is the amount of slop that Valgrind adds surrounding each heap allocation. That makes it more robust in the face of invalid writes.

I'm closing this as not a bug. If you fix the bug in your code and the segfault is still there please reopen this report.