Open ivmai opened 2 years ago
GC_expand_hp_inner /export/home/ivmai/bdwgc/extra/../alloc.c:336 :
static size_t min_bytes_allocd_minimum = 1;
...
static word min_bytes_allocd(void)
{
...
result = scan_size / GC_free_space_divisor;
if (GC_incremental) {
result /= 2;
}
return result > min_bytes_allocd_minimum // <-- line 336
? result : min_bytes_allocd_minimum;
}
GC_exclude_static_roots_inner /export/home/ivmai/bdwgc/extra/../mark_rts.c:580 :
struct exclusion * next;
...
if (0 == GC_excl_table_entries) {
next = 0;
} else {
next = GC_next_exclusion((ptr_t)start);
}
if (0 != next) { // <-- line 580
gcc -I include -O0 -fsanitize=memory tests/gctest.c extra/gc.c && ./a.out
==12626==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x2f9bc8 in GC_exclude_static_roots_inner /export/home/ivmai/bdwgc/extra/../mark_rts.c:600
I've created a small reproducible testcase.c:
#include <stddef.h>
typedef char * ptr_t;
struct exclusion {
ptr_t e_start;
ptr_t e_end;
};
struct _GC_arrays {
# define GC_excl_table_entries GC_arrays._excl_table_entries
size_t _excl_table_entries;
# define GC_excl_table GC_arrays._excl_table
struct exclusion _excl_table[512];
};
struct _GC_arrays GC_arrays = { 0 };
struct exclusion * next = 0;
void GC_exclude_static_roots_inner(void *start)
{
size_t next_index;
if (0 != next) {
size_t i;
next_index = 0;
for (i = GC_excl_table_entries; i > next_index; --i) {
GC_excl_table[i] = GC_excl_table[i-1];
}
} else {
next_index = GC_excl_table_entries;
}
GC_excl_table[next_index].e_start = (ptr_t)start;
}
int main(void) {
GC_exclude_static_roots_inner(0);
return 0;
}
gcc -O0 -g -fsanitize=memory testcase.c && ./a.out Output:
==16175==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x213790 in GC_exclude_static_roots_inner /export/home/ivmai/bdwgc/t.c:33
#1 0x2138e0 in main /export/home/ivmai/bdwgc/t.c:37
#2 0x4650607bf0d0 in __libc_start_main (/lib64/libc.so.6+0x220d0)
#3 0x2fec8 in _start (/export/home/ivmai/bdwgc/a.out+0x2fec8)
#4 0x46505ffd4298 in _start
As said by lcc folks, MSan is not yet supported properly by lcc (unlike ASan). I will close this issue after fixing it in lcc.
Source: master (2afde2458) Host: Linux/E2K Compiler: lcc:1.26.12:Jun--5-2022:e2k-v4-linux; gcc (GCC) 9.3.0 compatible How to reproduce (1): ./autogen.sh && ./configure && make -j check CFLAGS_EXTRA="-fsanitize=memory" && cat gctest.log
How to reproduce (2): ./autogen.sh && ./configure && make -j check CFLAGS_EXTRA="-fsanitize=memory -O0" && cat gctest.log
Related issue #411