From: Alan Hayward <Alan.Hayward@arm.com>
To: Pedro Alves <palves@redhat.com>
Cc: GDB Patches <gdb-patches@sourceware.org>, nd <nd@arm.com>
Subject: Re: [PATCH v3 3/3] Aarch64: Fix segfault when casting dummy calls
Date: Mon, 29 Oct 2018 11:58:00 -0000 [thread overview]
Message-ID: <3FFDA486-3FC8-4DA2-92C9-83C320F589F6@arm.com> (raw)
In-Reply-To: <201c7a49-ddf3-636a-f15a-eb9a4ccf284e@redhat.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3018 bytes --]
> On 24 Oct 2018, at 16:14, Pedro Alves <palves@redhat.com> wrote:
>
>>
>>>
>>> And what does "to ensure FUNC resolving" mean too, btw?
>>> AFAICT, the only reason to use a shared library is to
>>> compile it with or without debug information, right?
>>> Come to think of it, you could instead eliminate the
>>> shared library and compile a separate .o file instead, right?
>>> That would simplify the testcase a bit and expose it to more
>>> targets.
>>>
>>
>> I could only get the bug to expose itself when using a .so
>>
>> If I do the following using current HEAD then the bug is not present:
>>
>> g++ -c condbreak-solib-main.cc -o condbreak-solib-main.o -fno-inline
>> g++ -c condbreak-solib-lib.cc -o condbreak-solib-lib.o -fno-inline
>> g++ condbreak-solib-main.o condbreak-solib-lib.o
>>
>> It causes the type of the return value to be detected as
>> TYPE_CODE_PTR->TYPE_CODE_INT.
>
> Huh. That's really strange. Where is that pointer coming from?
>
> What does "ptype cmp3" say for you?
>
> (gdb) b foo if (int)cmp3("abc") == 1
> Breakpoint 1 at 0x40048b
> (gdb) ptype cmp3
> type = <unknown return type> ()
> (gdb) whatis cmp3
> type = <text variable, no debug info>
>
Yes, I get the same.
Sounds to me like there might still be an issue in gdb? Or at least
a difference in the way the type is calculated.
This on itâs own is still a good fix, so Iâll send a new version.
> I wonder if what you're looking at is actually the malloc call?
> GDB will call malloc to allocate space for the "abc" string in
> the inferior. Look at the backtrace, see where the call is coming
> from.
With the nodebug and debug shared library version:
(I need to run to main before I can set breakpoint on cmp3, otherwise
"Function "cmp3" not defined.â)
But with all versions, when stopped at cmp3, I get:
(gdb) bt
#0 0x00000000004005d4 in cmp3(char const*) ()
#1 <function called from gdb>
#2 0x00000000004005a4 in foo() ()
#3 0x00000000004005bc in main ()
>
> Actually, because of that, I think it would be better (more focused)
> to pass in a variable instead of "abc". You already have the
> unused variable "word" there:
>
> const char *word = "stuff";
>
> So:
>
> (gdb) b foo if (int)cmp3(word) == 1
>
> but please rename it to something else, because I tried that
> locally and there's another symbol called "word"
> in glibc's localeinfo.h, and gdb picks that one up.
Will do.
Using this still causes the bug in HEAD, so thatâs ok.
>
> Also, is there a reason for the test to be a C++ program?
> If there's none, it'd be better to make it a C program, again
> to expose it to more targets.
Switching to C causes the bug to vanish.
This is because C++ uses gnuv3_pass_by_reference(), and the
segfault happens inside there, whereas C uses
default_pass_by_reference(), which just returns 0.
Iâll expand the test to cover both C and C++.
Alan.\x16º&Öéj×!zÊÞ¶êç×}ïYb²Ö«r\x18\x1dnr\x17¬
next prev parent reply other threads:[~2018-10-29 11:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-11 14:49 [PATCH v3 0/3] " Alan Hayward
2018-10-11 14:49 ` [PATCH v3 2/3] Pass return_method to _push_dummy_call Alan Hayward
2018-10-19 11:31 ` Pedro Alves
2018-10-11 14:49 ` [PATCH v3 1/3] Use enum for return method for dummy calls Alan Hayward
2018-10-19 11:28 ` Pedro Alves
2018-10-11 14:49 ` [PATCH v3 3/3] Aarch64: Fix segfault when casting " Alan Hayward
2018-10-19 11:36 ` Pedro Alves
2018-10-23 16:08 ` Alan Hayward
2018-10-24 15:15 ` Pedro Alves
2018-10-29 11:58 ` Alan Hayward [this message]
[not found] ` <862cf8f4-9491-a1eb-251e-6c7c1ffffa6c@redhat.com>
2018-10-29 14:56 ` Alan Hayward
2018-10-29 18:13 ` Pedro Alves
2018-10-30 11:13 ` Alan Hayward
2018-10-30 16:31 ` Pedro Alves
2018-10-30 17:09 ` Alan Hayward
2018-10-30 17:40 ` Pedro Alves
2018-10-18 9:50 ` [PING][PATCH v3 0/3] " Alan Hayward
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=3FFDA486-3FC8-4DA2-92C9-83C320F589F6@arm.com \
--to=alan.hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=nd@arm.com \
--cc=palves@redhat.com \
/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