From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3535 invoked by alias); 3 Mar 2010 10:59:05 -0000 Received: (qmail 3515 invoked by uid 22791); 3 Mar 2010 10:59:04 -0000 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.83/v0.83-20-g38e4449) with ESMTP; Wed, 03 Mar 2010 10:59:00 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 410656D42F5; Wed, 3 Mar 2010 11:58:57 +0100 (CET) Date: Wed, 03 Mar 2010 10:59:00 -0000 From: Corinna Vinschen To: gdb-patches@sourceware.org Subject: Re: [RFA] defs.h: Define GDB_DEFAULT_TARGET_[WIDE_]CHARSET for Cygwin and MingW builds Message-ID: <20100303105857.GM17293@calimero.vinschen.de> Reply-To: gdb-patches@sourceware.org Mail-Followup-To: gdb-patches@sourceware.org References: <20100301103125.GB9730@calimero.vinschen.de> <20100301173054.GD5683@calimero.vinschen.de> <20100301193126.GA9416@caradoc.them.org> <20100303101630.GI17293@calimero.vinschen.de> <20100303104100.GJ17293@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100303104100.GJ17293@calimero.vinschen.de> User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00097.txt.bz2 On Mar 3 11:41, Corinna Vinschen wrote: > However, there's a problem in GDB which spoils the effort a bit. > > When GDB is started, setlocale() is called from captured_main(). > Afterwards, _initialize_charset() and, in turn, nl_langinfo() is > called, and the pointer returned by nl_langinfo(CODESET) is > stored as the name of the codeset. > So the codeset name is not copied into a safe storage area here, > just the pointer is memorized. > > Later, while captured_main() is still initializing GDB, the interp_set() > function is called, which calls tui_init(), which in turn initializes > readline. Readline calls setlocale(). Oops. The old pointer to > nl_langinfo(CODESET) might not be valid anymore afterwards. > > See the Linux manpage for nl_langinfo: > > RETURN VALUE > [...] > This pointer may point to static data that may be overwritten on the > next call to nl_langinfo() or setlocale(3). > > So, does anything speak against copying the codeset name into some > local storage, rather than just storing the pointer returned by > nl_langinfo? Accidentally omitted from my former mail: Since nl_langinfo is called only once here anyway, a simple auto_host_charset_name = strdup (nl_langinfo (CODESET)); would do. Corinna -- Corinna Vinschen Cygwin Project Co-Leader Red Hat