public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "thiago.bauermann at linaro dot org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/31254] [gdb, arm] FAIL: gdb.threads/staticthreads.exp: up 10
Date: Thu, 01 Feb 2024 03:24:42 +0000	[thread overview]
Message-ID: <bug-31254-4717-ouk076oF9h@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31254-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31254

--- Comment #17 from Thiago Jung Bauermann <thiago.bauermann at linaro dot org> ---
Created attachment 15347
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15347&action=edit
memcheck output of corruption problem

Valgrind pointed out what the problem is. I'm attaching the full output (the
line numbers may be a bit off due to some debug statements I added), but here
are the highlights:

As I mentioned in the previous comment, arm_find_exidx_entry () returns an
entry containing garbage. Then arm_exidx_fill_cache () reads it:

==3763513== Invalid read of size 1
==3763513==    at 0x3DE8CC: arm_exidx_fill_cache(frame_info_ptr, unsigned
char*) (arm-tdep.c:2865)
==3763513==    by 0x3DFFE1: arm_exidx_unwind_sniffer(frame_unwind const*,
frame_info_ptr, void**) (arm-tdep.c:3277)
==3763513==    by 0x6317ED: frame_unwind_try_unwinder(frame_info_ptr, void**,
frame_unwind const*) (frame-unwind.c:138)

The problem is that arm_exidx_new_objfile () stores the unwind instructions in
the objfile's obstack but it is freed before arm_exidx_fill_cache () has a
chance to use it:

==3763513==  Address 0xa128e10 is 608 bytes inside a block of size 4,072 free'd
==3763513==    at 0x4867A68: free (vg_replace_malloc.c:872)
==3763513==    by 0x374A3F: void xfree<void>(void*) (gdb-xfree.h:37)
==3763513==    by 0x518A351: obstack_free (obstack.c:357)
==3763513==    by 0x9A3B45: reread_symbols(int) (symfile.c:2587)
==3763513==    by 0x6C18CF: run_command_1(char const*, int, run_how)
(infcmd.c:398)
==3763513==    by 0x6C1CBB: run_command(char const*, int) (infcmd.c:512)

This happens because reread_symbols () detects that the staticthreads
executable has changed since it was loaded (I don't know why, though) and thus
reinitializes the objfile obstacks.

I'll see if I can make arm-tdep.c add a hook in objfiles_changed () so that it
can detect that the objfiles where reloaded and re-read the exception tables.
Or perhaps it's cleaner to convert objfiles_changed () into an observer.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2024-02-01  3:24 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 16:07 [Bug gdb/31254] New: " vries at gcc dot gnu.org
2024-01-17 16:08 ` [Bug gdb/31254] " vries at gcc dot gnu.org
2024-01-17 16:08 ` vries at gcc dot gnu.org
2024-01-17 16:12 ` vries at gcc dot gnu.org
2024-01-17 16:14 ` vries at gcc dot gnu.org
2024-01-17 16:19 ` vries at gcc dot gnu.org
2024-01-17 16:23 ` thiago.bauermann at linaro dot org
2024-01-17 16:37 ` luis.machado at arm dot com
2024-01-17 16:37 ` thiago.bauermann at linaro dot org
2024-01-17 16:44 ` thiago.bauermann at linaro dot org
2024-01-18 17:12 ` adhemerval.zanella at linaro dot org
2024-01-18 17:42 ` vries at gcc dot gnu.org
2024-01-18 19:15 ` thiago.bauermann at linaro dot org
2024-01-18 19:54 ` thiago.bauermann at linaro dot org
2024-01-19 10:32 ` vries at gcc dot gnu.org
2024-01-19 10:38 ` vries at gcc dot gnu.org
2024-01-24  2:51 ` thiago.bauermann at linaro dot org
2024-01-24  2:55 ` thiago.bauermann at linaro dot org
2024-01-31  4:03 ` thiago.bauermann at linaro dot org
2024-02-01  3:24 ` thiago.bauermann at linaro dot org [this message]
2024-02-01 10:04 ` vries at gcc dot gnu.org
2024-02-01 10:10 ` luis.machado at arm dot com
2024-02-01 18:32 ` thiago.bauermann at linaro dot org
2024-02-01 20:28 ` tdevries at suse dot de
2024-02-02  1:39 ` thiago.bauermann at linaro dot org
2024-02-03  3:26 ` thiago.bauermann at linaro dot org
2024-02-05  5:56 ` vries at gcc dot gnu.org
2024-02-05 10:04 ` cvs-commit at gcc dot gnu.org
2024-02-05 10:05 ` [Bug tdep/31254] [gdb/tdep, " vries at gcc dot gnu.org
2024-02-06 21:32 ` cvs-commit at gcc dot gnu.org
2024-02-06 21:33 ` cvs-commit at gcc dot gnu.org
2024-02-07  8:00 ` vries at gcc dot gnu.org

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-31254-4717-ouk076oF9h@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.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).