[PATCH] [ASan] Introduce the dump_instruction_bytes flag to print the faulting instruction upon SIGSEGV

Alexey Samsonov vonosmas at gmail.com
Wed Sep 3 17:35:54 PDT 2014


What if instruction pc points to is not in the zero page, but is inaccessible? It would be sad to crash the program while printing ASan error report in this case.

================
Comment at: lib/asan/asan_report.cc:162
@@ +161,3 @@
+void MaybeDumpInstructionBytes(uptr pc) {
+  if (!flags()->dump_instruction_bytes)
+    return;
----------------
You may check that pc < GetPageSizeCached() here.

================
Comment at: lib/asan/asan_report.cc:656
@@ -632,1 +655,3 @@
       GetCurrentTidOrInvalid());
+  if (pc < GetPageSizeCached()) {
+    Report("Hint: pc points to the zero page.\n");
----------------
We print pc above... do you really need this?

================
Comment at: lib/asan/asan_rtl.cc:234
@@ +233,3 @@
+
+  ParseFlag(str, &f->dump_instruction_bytes, "dump_instruction_bytes",
+      "If true, dump 16 bytes starting at the instruction that caused SEGV");
----------------
Wait, where is the default value for this flag?

================
Comment at: lib/sanitizer_common/sanitizer_posix_libcdep.cc:151
@@ -150,2 +150,3 @@
   sigact.sa_sigaction = (sa_sigaction_t)handler;
-  sigact.sa_flags = SA_SIGINFO;
+  // Do not block the signal from being received in that signal's handler.
+  // Clients are responsible for handling this correctly.
----------------
Can this go as a separate change?

http://reviews.llvm.org/D5167






More information about the llvm-commits mailing list