Repository navigation
Memory corruption in constexpr interpreter with GNU vector types #223
Closed
dkolsen-pgi
started this conversation in
Issue Triage - Compilation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
When the constexpr interpreter (interpret.c) is processing objects of GNU vector types, an out-of-bounds write may result in memory corruption and unpredictable results. I have seen the symptom be a front end seg fault or a failed assertion.
When the test program below is compiled with a debug build, ASan catches the out-of-bounds write:
The bug is in the definition of the macro
compute_prefix_size_for_typein interpret.c. Any object that contains subobjects needs to reserve space for a bitmap to keep track of which subobjects have been initialized. The problem is that GNU vector types (tk_vector) are not considered to be types with subobjects, so no space is reserved for the bitmap. But code elsewhere in the interpreter assumes that the bitmap is present, hence the memory corruption.I plan to provide a fix for this.
Reproducing Source Code
Command-line Options
eccp --g++ vec64.cpp
Type of Issue
[Front End] I do not care but this code CRASHES the compiler.
Additional Details
Since the failure is triggered by GNU vector types, GNU extensions need to be enabled.
Reproducing (Standard) Configuration(s)
linux-gcc-debug
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions