public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "avi at scylladb dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug sanitizer/105336] truncated address sanitizer stack traces
Date: Sun, 24 Apr 2022 12:17:00 +0000	[thread overview]
Message-ID: <bug-105336-4-2T0URXcKwp@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105336-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105336

--- Comment #5 from Avi Kivity <avi at scylladb dot com> ---
I reduced it to a few lines (attached, intentionally triggers use-after-free).
The culprit is -Og.

With

   g++ coroutine-asan.cc -o coroutine-asan --std=c++20 -fsanitize=address -Og

I see

READ of size 8 at 0x607000000020 thread T0
    #0 0x4018e2 in test() (/home/avi/tests/coroutine-asan+0x4018e2)
    #1 0x40192b in main (/home/avi/tests/coroutine-asan+0x40192b)
    #2 0x7fb2e0a1d58f in __libc_start_call_main (/lib64/libc.so.6+0x2d58f)
    #3 0x7fb2e0a1d648 in __libc_start_main_alias_1 (/lib64/libc.so.6+0x2d648)
    #4 0x401144 in _start (/home/avi/tests/coroutine-asan+0x401144)

0x607000000020 is located 0 bytes inside of 80-byte region
[0x607000000020,0x607000000070)
freed by thread T0 here:
    #0 0x7fb2e0fdebc8 in operator delete(void*) (/lib64/libasan.so.8+0xbbbc8)
    #1 0x40164f in
test_coroutine(test_coroutine(std::__n4861::coroutine_handle<void>&)::_Z14test_coroutineRNSt7__n486116coroutine_handleIvEE.Frame*)
[clone .actor] (/home/avi/tests/coroutine-asan+0x40164f)
    #2 0x40200f  (/home/avi/tests/coroutine-asan+0x40200f)

previously allocated by thread T0 here:
    #0 0x7fb2e0fde188 in operator new(unsigned long)
(/lib64/libasan.so.8+0xbb188)
    #1 0x4016c0 in test_coroutine(std::__n4861::coroutine_handle<void>&)
(/home/avi/tests/coroutine-asan+0x4016c0)


The stack traces are truncated, compared to

    g++ coroutine-asan.cc -o coroutine-asan --std=c++20 -fsanitize=address

which yields

READ of size 8 at 0x607000000020 thread T0
    #0 0x401cef in std::__n4861::coroutine_handle<void>::resume() const
(/home/avi/tests/coroutine-asan+0x401cef)
    #1 0x401b0f in test() (/home/avi/tests/coroutine-asan+0x401b0f)
    #2 0x401b85 in main (/home/avi/tests/coroutine-asan+0x401b85)
    #3 0x7f79b8be958f in __libc_start_call_main (/lib64/libc.so.6+0x2d58f)
    #4 0x7f79b8be9648 in __libc_start_main_alias_1 (/lib64/libc.so.6+0x2d648)
    #5 0x4011a4 in _start (/home/avi/tests/coroutine-asan+0x4011a4)

0x607000000020 is located 0 bytes inside of 80-byte region
[0x607000000020,0x607000000070)
freed by thread T0 here:
    #0 0x7f79b91aabc8 in operator delete(void*) (/lib64/libasan.so.8+0xbbbc8)
    #1 0x4019a5 in
test_coroutine(test_coroutine(std::__n4861::coroutine_handle<void>&)::_Z14test_coroutineRNSt7__n486116coroutine_handleIvEE.Frame*)
[clone .actor] (/home/avi/tests/coroutine-asan+0x4019a5)
    #2 0x401cf7 in std::__n4861::coroutine_handle<void>::resume() const
(/home/avi/tests/coroutine-asan+0x401cf7)
    #3 0x401b0f in test() (/home/avi/tests/coroutine-asan+0x401b0f)
    #4 0x401b85 in main (/home/avi/tests/coroutine-asan+0x401b85)
    #5 0x7f79b8be958f in __libc_start_call_main (/lib64/libc.so.6+0x2d58f)

previously allocated by thread T0 here:
    #0 0x7f79b91aa188 in operator new(unsigned long)
(/lib64/libasan.so.8+0xbb188)
    #1 0x401293 in test_coroutine(std::__n4861::coroutine_handle<void>&)
(/home/avi/tests/coroutine-asan+0x401293)
    #2 0x401af9 in test() (/home/avi/tests/coroutine-asan+0x401af9)
    #3 0x401b85 in main (/home/avi/tests/coroutine-asan+0x401b85)
    #4 0x7f79b8be958f in __libc_start_call_main (/lib64/libc.so.6+0x2d58f)


The traces go all the away to main.

  parent reply	other threads:[~2022-04-24 12:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 14:37 [Bug sanitizer/105336] New: " avi at scylladb dot com
2022-04-21 14:53 ` [Bug sanitizer/105336] " avi at scylladb dot com
2022-04-22  6:07 ` rguenth at gcc dot gnu.org
2022-04-23 16:34 ` avi at scylladb dot com
2022-04-24 12:16 ` avi at scylladb dot com
2022-04-24 12:17 ` avi at scylladb dot com [this message]
2022-04-24 12:18 ` avi at scylladb dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105336-4-2T0URXcKwp@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).