From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.134]) by sourceware.org (Postfix) with ESMTPS id 326073858CDA; Fri, 12 Aug 2022 10:50:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 326073858CDA Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=cygwin.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=cygwin.com Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MGxYh-1o8vqj45wp-00E4hn; Fri, 12 Aug 2022 12:50:03 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id 261FBA8078A; Fri, 12 Aug 2022 12:50:02 +0200 (CEST) Date: Fri, 12 Aug 2022 12:50:02 +0200 From: Corinna Vinschen To: cygwin@cygwin.com, newlib@sourceware.org Subject: Re: crash in newlocale() Message-ID: Mail-Followup-To: cygwin@cygwin.com, newlib@sourceware.org References: <20220811211806.bc7f5426ce52f57d1c1538c2@nifty.ne.jp> <20220812083855.55b416d464ec153ea3280f4c@nifty.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220812083855.55b416d464ec153ea3280f4c@nifty.ne.jp> X-Provags-ID: V03:K1:8RjW6MdXlXi/gH3gwdutMdt07UZrK9JNddALTPuRJANdnLtWrMr 2HMQRJt3vMflZ8pxBQHT9i0enLwJnfb2HWz629JWW2ruA0LVlugyF3SkgZxyYJZO2nDt6gX cLOcIvFSpra4hm6VyfZOmipv85ZANw35DDnYrEzUNLRkG0gj50L/pNvCzsYe/06Aa3+3zxP nX1QW626tRZcX8UUADJPQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:B/GLQJmK2N8=:QCBSaN0RYfzsc4IeRhCkyM ZRGK1wW9S+J/w446J5YIfq40LD6icGVZ8QlQ97SAvq8Qcf/ws2TEtpSli+0JPEWjbyMCsa5xi YezkS4gWiWvCJ7ak4vT4KiXXaU/30wDL5Imtln2lwYnHZH72rLrvI7m8WqXHizZndGgJaJ13j XH3OML6+kww6C0eLks0G38QSQ25am9E0D223CmIREYklTAPqbKHJ0PWETV5ZrqVLhZ9R8rTg0 ywbSNH3ZWNIQOmQ9ScI4wzhD6WPhu6ulSEDGpXiSdanJm5zRFYTsxoJSfu5rA+Fh1cQW1+doc MzmfeOlIngQEpABcTd05gw4NZTKSOnkWd/LpEUjAPjO7RHx3ao9ZXhBOjqjlSHF9fm1A26gZq 030iwzmfGL5Yaf6kqjZVLG69mnixQ6VQsUdIfTzGHdG0yb10nGQRePwtxbFHpaKlDgwKkb79N 1uKOrVIhXXv9zXcULf9b1YLBVWxeVDAx4yqNhsqwATGKaq1jR5VZzxTt9KxHzVhVgrnsk388P fxNmMflH77Aa+VViE3Cj9rXzAUQTXTQdTBh9E2d05lCgaiKFXCsVFPqtbqOd68OtrGlcwgeNp ZJge72bIn7gPNy1F+T8+z66yrbI2Aui2VYascis1tLhTGEl2DPgi9zEyDfK7DHUcnlTeoGME0 SvDwrbYN/3Zxw0ZlB86Gh1dWp/H9+0I9p0VFLcGZKICOBY5xbJMi6fLcpH+ziJmfcBLdXFs++ Nlv/EzvqMHeLFaFXsmyLp2JDDaKpg6/xmWVz09ESVWkrIJ1sqrQHQ+jP6FY= X-Spam-Status: No, score=-95.8 required=5.0 tests=BAYES_00, GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_FAIL, SPF_HELO_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2022 10:50:06 -0000 On Aug 12 08:38, Takashi Yano wrote: > On Thu, 11 Aug 2022 19:35:39 +0200 > Corinna Vinschen wrote: > > On Aug 11 21:18, Takashi Yano wrote: > > > On Thu, 11 Aug 2022 11:29:28 +1000 > > > Tony Cook wrote: > > > > Hello everyone, > > > > > > > > While tracking down a crash in development versions of perl the boostrap > > > > miniperl executable was crashing early in the build process: > > > > [...] > > > > > > I looked into this problem and found the access violation > > > occurs at: > > > newlib/libc/locale/newlocale.c > > > @@ 188,7 @@ _newlocale_r (struct _reent *p, int category_mask, const char *locale, > > > if (tmp_locale.lc_cat[i].buf == (const void *) -1) > > > { > > > tmp_locale.lc_cat[i].buf = base->lc_cat[i].buf; > > > base->lc_cat[i].ptr = base->lc_cat[i].buf = NULL; <-- Here!!! > > > } > > > #endif /* __HAVE_LOCALE_INFO__ */ > > > _freelocale_r (p, base); > > > > > > This is because > > > locale_t st = newlocale(LC_ALL_MASK, "C", (locale_t)0); > > > returns > > > extern const struct __locale_t __C_locale; > > > return (struct __locale_t *) &__C_locale; > > > , which is in the const area that cannot be modified. > > > [...] > > I think the right thing to do is to avoid freeing this data, if the base > > locale is the C locale. I sent a patch to cygwin-patches for review. > > Can you please take a look? > > LGTM. Thanks! Thanks for checking! I pushed the patch with addition release msg to the 3.3 branch as well. Corinna