public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Crash of Archer's gdb on mingw (passing null argument to vasprintf)
@ 2011-10-03  9:39 Joost van der Sluis
  2011-10-03 10:07 ` Mark Kettenis
  2011-10-03 14:59 ` Joel Brobecker
  0 siblings, 2 replies; 7+ messages in thread
From: Joost van der Sluis @ 2011-10-03  9:39 UTC (permalink / raw)
  To: gdb

Hi all,

Maybe a strange question because it's not about stock gdb but about the
fedora16-branch from the Archer project. But I know that there are not
that much mingw/Windows people on the Archer mailinglist, so I ask here.

In gdbtypes.c there's this code:

    warning (_("Range for type %s has invalid bounds %s..%s"),
            TYPE_NAME (type), plongest (TYPE_LOW_BOUND (range_type)),
            plongest (TYPE_HIGH_BOUND (range_type)));

This goes wrong when TYPE_NAME (type) is null. Eventually warning()
leads to a call of vasprintf(), and on Fedora it prints '(NULL)' when it
encounters a null-parameter. But on mingw it crashes (sigint).

How to fix this properly? I could add a check for the assignment of
TYPE_NAME (type). Or should mingw fix their vasprintf implementation? Or
can I switch to another version of casprintf? (I use the
mingw-installation from Fedora to cross-compile to mingw)

Joost van der Sluis.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Crash of Archer's gdb on mingw (passing null argument to vasprintf)
  2011-10-03  9:39 Crash of Archer's gdb on mingw (passing null argument to vasprintf) Joost van der Sluis
@ 2011-10-03 10:07 ` Mark Kettenis
  2011-10-03 14:59 ` Joel Brobecker
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Kettenis @ 2011-10-03 10:07 UTC (permalink / raw)
  To: joost; +Cc: gdb

> From: Joost van der Sluis <joost@cnoc.nl>
> Date: Mon, 03 Oct 2011 11:39:37 +0200
> 
> Hi all,
> 
> Maybe a strange question because it's not about stock gdb but about the
> fedora16-branch from the Archer project. But I know that there are not
> that much mingw/Windows people on the Archer mailinglist, so I ask here.
> 
> In gdbtypes.c there's this code:
> 
>     warning (_("Range for type %s has invalid bounds %s..%s"),
>             TYPE_NAME (type), plongest (TYPE_LOW_BOUND (range_type)),
>             plongest (TYPE_HIGH_BOUND (range_type)));
> 
> This goes wrong when TYPE_NAME (type) is null. Eventually warning()
> leads to a call of vasprintf(), and on Fedora it prints '(NULL)' when it
> encounters a null-parameter. But on mingw it crashes (sigint).
> 
> How to fix this properly? I could add a check for the assignment of
> TYPE_NAME (type). Or should mingw fix their vasprintf implementation? Or
> can I switch to another version of casprintf? (I use the
> mingw-installation from Fedora to cross-compile to mingw)

The C standard doesn't say that printf("%s", NULL) should be treated
specially, so having things crash just as the would for printf("%s",
p) where p is an invalid pointer is perfectly fine.  So blindly
printing TYPE_NAME (type) clearly is the problem here.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Crash of Archer's gdb on mingw (passing null argument to vasprintf)
  2011-10-03  9:39 Crash of Archer's gdb on mingw (passing null argument to vasprintf) Joost van der Sluis
  2011-10-03 10:07 ` Mark Kettenis
@ 2011-10-03 14:59 ` Joel Brobecker
  2011-10-03 16:17   ` Joost van der Sluis
  1 sibling, 1 reply; 7+ messages in thread
From: Joel Brobecker @ 2011-10-03 14:59 UTC (permalink / raw)
  To: Joost van der Sluis; +Cc: gdb

> In gdbtypes.c there's this code:
> 
>     warning (_("Range for type %s has invalid bounds %s..%s"),
>             TYPE_NAME (type), plongest (TYPE_LOW_BOUND (range_type)),
>             plongest (TYPE_HIGH_BOUND (range_type)));
> 
> This goes wrong when TYPE_NAME (type) is null.

We should several example of us handling this type of situation.
Typically we use:

        TYPE_NAME (type) ? TYPE_NAME (type) : "<anonymous>"

or something like that.
-- 
Joel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Crash of Archer's gdb on mingw (passing null argument to vasprintf)
  2011-10-03 14:59 ` Joel Brobecker
@ 2011-10-03 16:17   ` Joost van der Sluis
  2011-10-03 16:25     ` Joel Brobecker
  2011-10-03 16:35     ` Jan Kratochvil
  0 siblings, 2 replies; 7+ messages in thread
From: Joost van der Sluis @ 2011-10-03 16:17 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb

[-- Attachment #1: Type: text/plain, Size: 808 bytes --]

On Mon, 2011-10-03 at 07:59 -0700, Joel Brobecker wrote:
> > In gdbtypes.c there's this code:
> > 
> >     warning (_("Range for type %s has invalid bounds %s..%s"),
> >             TYPE_NAME (type), plongest (TYPE_LOW_BOUND (range_type)),
> >             plongest (TYPE_HIGH_BOUND (range_type)));
> > 
> > This goes wrong when TYPE_NAME (type) is null.
> 
> We should several example of us handling this type of situation.
> Typically we use:
> 
>         TYPE_NAME (type) ? TYPE_NAME (type) : "<anonymous>"

I've found the TYPE_ERROR_NAME macro. Now another question: how do I
send a patch for inclusion in gdb? Can I send it to this list? Or
gdb-patches?

btw: patch is attached. First part will only apply to Archer though. (My
guess is the archer-jankratochvil-vla branch)

Regards,

Joost van der Slui

[-- Attachment #2: TYPE_NAME_fix.diff --]
[-- Type: text/x-patch, Size: 998 bytes --]

--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1527,7 +1544,7 @@ type_length_get (struct type *type, struct type *target_type, int full_span)
   /* It may happen for wrong DWARF annotations returning garbage data.  */
   if (count < 0)
     warning (_("Range for type %s has invalid bounds %s..%s"),
-	     TYPE_NAME (type), plongest (TYPE_LOW_BOUND (range_type)),
+	     TYPE_ERROR_NAME (type), plongest (TYPE_LOW_BOUND (range_type)),
 	     plongest (TYPE_HIGH_BOUND (range_type)));
   /* The code below does not handle count == 0 right.  */
   if (count <= 0)
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -319,7 +319,7 @@ gnuv3_rtti_type (struct value *value,
       || strncmp (vtable_symbol_name, "vtable for ", 11))
     {
       warning (_("can't find linker symbol for virtual table for `%s' value"),
-	       TYPE_NAME (values_type));
+	       TYPE_ERROR_NAME (values_type));
       if (vtable_symbol_name)
 	warning (_("  found `%s' instead"), vtable_symbol_name);
       return NULL;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Crash of Archer's gdb on mingw (passing null argument to vasprintf)
  2011-10-03 16:17   ` Joost van der Sluis
@ 2011-10-03 16:25     ` Joel Brobecker
  2011-10-12  7:30       ` Joost van der Sluis
  2011-10-03 16:35     ` Jan Kratochvil
  1 sibling, 1 reply; 7+ messages in thread
From: Joel Brobecker @ 2011-10-03 16:25 UTC (permalink / raw)
  To: Joost van der Sluis; +Cc: gdb

> I've found the TYPE_ERROR_NAME macro.

Heh - I didn't know about this one.

> Now another question: how do I send a patch for inclusion in gdb? Can
> I send it to this list? Or gdb-patches?

It is preferable that you submit patches upstream if they apply there.
In that case, please send them to gdb-patches.  If they only apply
to project Archer, then you should send them to the archer list.

You should review the contents of the gdb/CONTRIBUTE file, which gives
the initial pointers on how to submit a patch.  You're not far off
in this case, but you are missing a ChangeLog entry.

You might also want to start a copyright assignment process if you
are planning on contributing again. We can take one, or maybe two
small patches, but beyond that, we almost always require that
the contributor have an assignment on file.

-- 
Joel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Crash of Archer's gdb on mingw (passing null argument to vasprintf)
  2011-10-03 16:17   ` Joost van der Sluis
  2011-10-03 16:25     ` Joel Brobecker
@ 2011-10-03 16:35     ` Jan Kratochvil
  1 sibling, 0 replies; 7+ messages in thread
From: Jan Kratochvil @ 2011-10-03 16:35 UTC (permalink / raw)
  To: Joost van der Sluis; +Cc: Joel Brobecker, gdb

On Mon, 03 Oct 2011 18:16:38 +0200, Joost van der Sluis wrote:
> btw: patch is attached. First part will only apply to Archer though. (My
> guess is the archer-jankratochvil-vla branch)

I have applied it to archer-jankratochvil-vla
(fb9d144c4cb4152a1e20e8fecf58ff556fd110d6).

Still the second part needs to go through the standard FSF GDB contribution
process, as suggested by Joel.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Crash of Archer's gdb on mingw (passing null argument to vasprintf)
  2011-10-03 16:25     ` Joel Brobecker
@ 2011-10-12  7:30       ` Joost van der Sluis
  0 siblings, 0 replies; 7+ messages in thread
From: Joost van der Sluis @ 2011-10-12  7:30 UTC (permalink / raw)
  To: gdb

On Mon, 2011-10-03 at 09:25 -0700, Joel Brobecker wrote:
> > I've found the TYPE_ERROR_NAME macro.
> 
> Heh - I didn't know about this one.

But it seems to be the wrong one? Pierre mailed me that this one should
be used for erroneous types. This is not the case here, it just doesn't
have a name. I'll send another patch to gdb-patches.

> You might also want to start a copyright assignment process if you
> are planning on contributing again. We can take one, or maybe two
> small patches, but beyond that, we almost always require that
> the contributor have an assignment on file.

I do have all those papers in order, for some patches to the vla-branch.

Regards,

Joost van der Sluis

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-10-12  7:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-03  9:39 Crash of Archer's gdb on mingw (passing null argument to vasprintf) Joost van der Sluis
2011-10-03 10:07 ` Mark Kettenis
2011-10-03 14:59 ` Joel Brobecker
2011-10-03 16:17   ` Joost van der Sluis
2011-10-03 16:25     ` Joel Brobecker
2011-10-12  7:30       ` Joost van der Sluis
2011-10-03 16:35     ` Jan Kratochvil

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).