This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 0/2] Aarch64: Fix segfault when casting dummy calls



> On 10 Oct 2018, at 09:23, Pedro Alves <palves@redhat.com> wrote:
> 
> On 10/09/2018 06:50 PM, Alan Hayward wrote:
>> 
>> 
>>> On 9 Oct 2018, at 17:10, Pedro Alves <palves@redhat.com> wrote:
>>> 
>>> On 10/01/2018 04:52 PM, Alan Hayward wrote:
>>>> This is a reworking of a patch I posted in March.
>>>> V1 had a long discussion which was then paused to wait for
>>>> Pedro's IFUNC rewrite.
>>>> 
>>>> 
>>>> Prevent the int cast in the following causing a segfault on aarch64:
>>>> (gdb) b foo if (int)strcmp(name,"abc") == 0
>>>> (gdb) run
>>>> 
>>>> 
>>>> This is because to aarch64_push_dummy_call determines the return type
>>>> of the function and then does not check for null pointer.
>>>> 
>>>> A null pointer for the return type means either 1) the call has a
>>>> cast or 2) an error has occured.
>>> 
>>> I'd think that "1) the call has a cast" is not accurate.
>>> If the called function has debug info, then GDB will know
>>> it's return type.  The issue is that the called function may
>>> not have debug information, and then GDB does not know
>>> its return type (so its NULL), and then the only way to
>>> call the function is to add the cast.  Right?
>>> 
>> 
>> That makes sense. I’d add that in the above example I’m able to do the
>> break without a cast and gdb does not segfault - the return type
>> of the function comes back as an int. 
> 
> Please double check whether the proposed testcase crashes GDB without
> the fix.  I suspect not, due to the library being compiled with
> debug info.  If it does crash, then I think I'm missing something.
> 

Checking this on latest clean head:

b cmp3 if (int)strcmp(word,"stuff") == 0
 - segfault

b cmp3 if strcmp(word,"stuff") == 0
 - works. Gdb complains that strcmp has unknown return type.

b bar if cmp3("stuff") == 0
 - works.

b bar if (char)cmp3("stuff") == 0
 - works.

I think I’ve gotten a little muddled when writing my test. I should instead
be compiling the library without debug info. And then do a conditional
break using cmp3 instead of strcmp. I’ll rework this in a v3.







Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]