This is the mail archive of the
mailing list for the GDB project.
Re: Crash of Archer's gdb on mingw (passing null argument to vasprintf)
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: joost at cnoc dot nl
- Cc: gdb at sourceware dot org
- Date: Mon, 3 Oct 2011 12:07:00 +0200 (CEST)
- Subject: Re: Crash of Archer's gdb on mingw (passing null argument to vasprintf)
- References: <firstname.lastname@example.org>
> From: Joost van der Sluis <email@example.com>
> 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.