https://bugs.kde.org/show_bug.cgi?id=492255

            Bug ID: 492255
           Summary: Hangs before main() on any code compiled with clang
                    -fsanitize=memory
    Classification: Developer tools
           Product: valgrind
           Version: 3.20.0
          Platform: Debian unstable
                OS: Linux
            Status: REPORTED
          Severity: grave
          Priority: NOR
         Component: memcheck
          Assignee: jsew...@acm.org
          Reporter: marko.mak...@iki.fi
  Target Milestone: ---

SUMMARY

Valgrind gets into a seemingly infinite loop when executing a trivial program
that was compiled with clang -fsanitize=memory (MemorySanitizer).

STEPS TO REPRODUCE

1. echo "int main(){return 0;}" > m.c
2. clang -fsanitize=memory m.c
3. valgrind ./a.out

OBSERVED RESULT

==1186257== Memcheck, a memory error detector
==1186257== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==1186257== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==1186257== Command: ./a.out
==1186257== 
==1186257== Warning: set address range perms: large range [0x10000000000,
0x100000000000) (defined)

This is followed by 100% CPU usage in Valgrind, inside a call stack that
includes multiple avl_insert() inside vgSysWrap_amd64_linux_sys_mmap_before().

EXPECTED RESULT

Valgrind should refuse to run the program, similar to when -fsanitize=address
is used:

==1186156== Memcheck, a memory error detector
==1186156== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==1186156== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==1186156== Command: ./a.out
==1186156== 
==1186156==Shadow memory range interleaves with an existing memory mapping.
ASan cannot proceed correctly. ABORTING.
==1186156==ASan shadow was supposed to be located in the
[0x00007fff7000-0x10007fff7fff] range.
==1186156==This might be related to ELF_ET_DYN_BASE change in Linux 4.12.
==1186156==See https://github.com/google/sanitizers/issues/856 for possible
workarounds.
==1186156==Process memory map follows:
…
==1186156==End of process memory map.
==1186156== 
==1186156== HEAP SUMMARY:
==1186156==     in use at exit: 0 bytes in 0 blocks
==1186156==   total heap usage: 86 allocs, 86 frees, 2,737 bytes allocated
==1186156== 
==1186156== All heap blocks were freed -- no leaks are possible
==1186156== 
==1186156== For lists of detected and suppressed errors, rerun with: -s
==1186156== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

SOFTWARE/OS VERSIONS

dpkg --status valgrind|grep Version
Version: 1:3.20.0-2.1
dpkg --status clang-18|grep Version
Version: 1:18.1.8-9

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to