This is an archive of the discontinued LLVM Phabricator instance.

Fix insertion of `sanitizer_cov_trace_pc_guard` insertion in optimized code with debug info
AbandonedPublic

Authored by mehdi_amini on Feb 23 2017, 12:04 PM.

Details

Reviewers
kcc
Summary

It is illegal to have a call without debug info attached in a function
with debug info: it'll crash the backend.
However this pattern can happen after jump-threading, so we need to be
robust against this. The instrumentation was only looking at the block
entry, if there is no debug location there we will now default to the
function's one.

Event Timeline

mehdi_amini created this revision.Feb 23 2017, 12:04 PM
kcc edited edge metadata.Feb 23 2017, 12:42 PM

is it possible to add an assert() that fails now and gets fixed with your patch?

In D30307#684972, @kcc wrote:

is it possible to add an assert() that fails now and gets fixed with your patch?

piping to llc hits an assert today, I'm not sure it'd be appropriate to use llc here just for this purpose though?

kcc accepted this revision.Feb 23 2017, 12:45 PM

LGTM
(but not claiming to understand the problem)

This revision is now accepted and ready to land.Feb 23 2017, 12:45 PM

fix test to fail the verifier

In D30307#684976, @kcc wrote:

LGTM
(but not claiming to understand the problem)

OK, so this patch might not be needed (even though having a better failure here could be helpful). I returned to my original test case to have another look. The verifier is crashing so no need for llc, I updated the test-case. What is needed is the *definition* for the runtime function. This seems to indicate that I'm instrumenting the runtime, which does not seem correct.
My clang is crashing when building for running make check-fuzzer right now, this is how I hit this.

The crash happened in llvm/lib/Fuzzer/FuzzerTracePC.cpp with this invocation:

/Users/mehdi_amini/projects/vanilla/clang/ReleaseAssert/bin/clang++ -DLLVM_BUILD_GLOBAL_ISEL -D_DEBUG -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Fuzzer -I/Users/mehdi_amini/projects/vanilla/clang/llvm-project/llvm/lib/Fuzzer -Iinclude -I/Users/mehdi_amini/projects/vanilla/clang/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Werror=date-time -std=c++11 -fno-omit-frame-pointer -O1 -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp -fcolor-diagnostics -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters -Werror -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -MD -MT lib/Fuzzer/CMakeFiles/LLVMFuzzerNoMainObjects.dir/FuzzerTracePC.cpp.o -MF lib/Fuzzer/CMakeFiles/LLVMFuzzerNoMainObjects.dir/FuzzerTracePC.cpp.o.d -o lib/Fuzzer/CMakeFiles/LLVMFuzzerNoMainObjects.dir/FuzzerTracePC.cpp.o -c /Users/mehdi_amini/projects/vanilla/clang/llvm-project/llvm/lib/Fuzzer/FuzzerTracePC.cpp -g

See the -fsanitize-coverage=trace-pc-guard,.. without trace-pc-guard being present in the -fno-sanitize-coverage. I think I'm faulty as I was playing with the CMakefiles right now.

mehdi_amini abandoned this revision.Mar 27 2017, 9:56 PM