From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 87751 invoked by alias); 13 Apr 2015 19:07:36 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 87678 invoked by uid 48); 13 Apr 2015 19:07:32 -0000 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/65749] sanitizer stack trace pc off by 1 Date: Mon, 13 Apr 2015 19:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-04/txt/msg01053.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65749 --- Comment #1 from Martin Sebor --- Replacing the computation: uptr pc = GetPreviousInstructionPc(trace[i]); with the assignment: uptr pc = trace[i]; makes the PC in active frame in the stack trace consistent with the one reported on the ERROR: AddressSanitizer line, and the (return) addresses in frames #1 and beyond consistent with those printed by GDB. This patch however causes regressions in a number of asan tests due to changes in the line numbers. An example is the stack-overflow-1.c test which is reported as failing due to the change in the faulting line number in the stack trace from the expected 16 to 13: FAIL: c-c++-common/asan/stack-overflow-1.c -O2 output pattern test, is ================================================================= ==14778==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff29383d3a at pc 0x000000400966 bp 0x7fff29383d00 sp 0x7fff29383cf8 READ of size 1 at 0x7fff29383d3a thread T0 #0 0x400966 in main c-c++-common/asan/stack-overflow-1.c:13 #1 0x7f1ad7283fe0 in __libc_start_main (/lib64/libc.so.6+0x1ffe0) #2 0x4009f5 (/home/msebor/build/gcc-65479/gcc/testsuite/gcc/stack-overflow-1.exe+0x4009f5) The line number reported by the patched sanitizer matches the line number reported by tools like addr2line and readelf --debug-dump=decodedline: $ addr2line 0x400966 /home/msebor/fsf/gcc-git/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c:13 The complete line program for the test looks like this: $ readelf --debug-dump=decodedline a.out Decoded dump of debug contents of section .debug_line: CU: /home/msebor/fsf/gcc-git/libsanitizer/sanitizer_common/sanitizer_stacktrace.h: File name Line number Starting address CU: /home/msebor/fsf/gcc-git/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c: File name Line number Starting address stack-overflow-1.c 13 0x4008f6 stack-overflow-1.c 15 0x40096e stack-overflow-1.c 16 0x400984 stack-overflow-1.c 17 0x4009d7 stack-overflow-1.c 13 0x4009dd stack-overflow-1.c 18 0x400a21 stack-overflow-1.c 18 0x400a2e stack-overflow-1.c 18 0x400a32 stack-overflow-1.c 18 0x400a43 stack-overflow-1.c 18 0x400a47