From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23376 invoked by alias); 3 Oct 2011 10:07:31 -0000 Received: (qmail 23365 invoked by uid 22791); 3 Oct 2011 10:07:30 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 03 Oct 2011 10:07:06 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3) with ESMTP id p93A71Q3023851; Mon, 3 Oct 2011 12:07:01 +0200 (CEST) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3/Submit) id p93A70B8019170; Mon, 3 Oct 2011 12:07:00 +0200 (CEST) Date: Mon, 03 Oct 2011 10:07:00 -0000 Message-Id: <201110031007.p93A70B8019170@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: joost@cnoc.nl CC: gdb@sourceware.org In-reply-to: <1317634777.28003.15.camel@feddie.cnoc.lan> (message from Joost van der Sluis on Mon, 03 Oct 2011 11:39:37 +0200) Subject: Re: Crash of Archer's gdb on mingw (passing null argument to vasprintf) References: <1317634777.28003.15.camel@feddie.cnoc.lan> Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-10/txt/msg00004.txt.bz2 > From: Joost van der Sluis > 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.