X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA132385AE41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1660301471; bh=x9TPRWSOKtfktwx/xf3cjmiocW3u9dVz5Gqpk2yZYfU=; h=Date:From:To:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=hduT5H0tjtPKUsjoahzeuYmp6YBpUIQc4QEICdKUyhYmjb4NWpuENXNHHW4Hc+NNA xQ3K2RgZvdauOuiC5rN3e+yaoZduRI+feoDz/ldsdz8AYj6O5SmQmiWSHl0hTdfyHD U5RdlrFTJh2wYtNsTK7b1UQM5QNY12XxcDORv3cQ= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com 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 Date: Fri, 12 Aug 2022 12:50:02 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com, newlib AT sourceware DOT org Subject: Re: crash in newlocale() Message-ID: Mail-Followup-To: cygwin AT cygwin DOT com, newlib AT sourceware DOT org References: <20220811211806 DOT bc7f5426ce52f57d1c1538c2 AT nifty DOT ne DOT jp> <20220812083855 DOT 55b416d464ec153ea3280f4c AT nifty DOT ne DOT jp> MIME-Version: 1.0 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 AT cygwin DOT 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" 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 -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple