delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/08/10/21:30:53

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 976DD3857B98
Authentication-Results: sourceware.org; dmarc=none (p=none dis=none)
header.from=develop-help.com
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=develop-help.com
Date: Thu, 11 Aug 2022 11:29:28 +1000
From: Tony Cook <tony AT develop-help DOT com>
To: cygwin AT cygwin DOT com
Subject: crash in newlocale()
Message-ID: <YvRbeAzxwtYwhkkE@venus.tony.develop-help.com>
MIME-Version: 1.0
X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
KAM_SHORT, SPF_HELO_NONE, SPF_PASS, 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
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

Hello everyone,

While tracking down a crash in development versions of perl the boostrap
miniperl executable was crashing early in the build process:

$ gdb --args ./miniperl -e0
GNU gdb (GDB) (Cygwin 11.2-1) 11.2
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-cygwin".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./miniperl...
(gdb) b locale.c:1154
Breakpoint 1 at 0x10077db13: file locale.c, line 1154.
(gdb) r
Starting program: /home/tony/dev/perl/git/perl/miniperl -e0
[New Thread 13624.0x1c7c]
[New Thread 13624.0x1978]
[New Thread 13624.0x2958]
[New Thread 13624.0x3374]

Thread 1 "miniperl" hit Breakpoint 1, S_emulate_setlocale_i (my_perl=0x800049910, index=0, new_locale=0x800066628 "en_US.UTF-8", recalc_LC_ALL=-1, line=4026) at locale.c:1154
1154            new_obj = newlocale(mask, new_locale, basis_obj);
(gdb) bt
#0  S_emulate_setlocale_i (my_perl=0x800049910, index=0,
    new_locale=0x800066628 "en_US.UTF-8", recalc_LC_ALL=-1, line=4026)
    at locale.c:1154
#1  0x0000000100783849 in Perl_init_i18nl10n (my_perl=0x800049910, printwarn=1)
    at locale.c:4026
#2  0x0000000100443c80 in perl_construct (my_perl=0x800049910)
    at /home/tony/dev/perl/git/perl/perl.c:447
#3  0x00000001007b7483 in main (argc=2, argv=0xffffcc30, env=0x8000281a0)
    at miniperlmain.c:108
(gdb) p mask
$1 = 4
(gdb) p new_locale
$2 = 0x800066628 "en_US.UTF-8"
(gdb) p basis_obj
$3 = (locale_t) 0x1802b3060 <__C_locale>
(gdb) n

Thread 1 "miniperl" received signal SIGSEGV, Segmentation fault.
0x000000080004a310 in ?? ()
(gdb) bt
#0  0x000000080004a310 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

While I get a SEGV from miniperl, a simple reproducer returns a
SIGTRAP:

tony AT enceladus ~/dev/perl/git
$ cat newlocale-test.c
#include <locale.h>
#include <stdio.h>

int main() {
  locale_t st = newlocale(LC_ALL_MASK, "C", (locale_t)0);

  locale_t st2 = newlocale(LC_CTYPE_MASK, "en_US.UTF-8", st);
  printf("Done\n");
  return 0;
}
tony AT enceladus ~/dev/perl/git
$ gcc -onewlocale-test -g newlocale-test.c

tony AT enceladus ~/dev/perl/git
$ gdb ./newlocale-test.exe
GNU gdb (GDB) (Cygwin 11.2-1) 11.2
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-cygwin".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./newlocale-test.exe...
(gdb) r
Starting program: /home/tony/dev/perl/git/newlocale-test.exe
[New Thread 9176.0x3a8c]
[New Thread 9176.0x2014]
[New Thread 9176.0x2bc4]
[Thread 9176.0x2014 exited with code 3221225477]
[Thread 9176.0x3a8c exited with code 3221225477]
[Thread 9176.0x2bc4 exited with code 3221225477]

Program terminated with signal SIGTRAP, Trace/breakpoint trap.
The program no longer exists.
(gdb) b main
Breakpoint 1 at 0x10040108d: file newlocale-test.c, line 5.
(gdb) r
Starting program: /home/tony/dev/perl/git/newlocale-test.exe
[New Thread 13668.0x2a7c]
[New Thread 13668.0x15a0]
[New Thread 13668.0x2158]

Thread 1 "newlocale-test" hit Breakpoint 1, main () at newlocale-test.c:5
5         locale_t st = newlocale(LC_ALL_MASK, "C", (locale_t)0);
(gdb) n
7         locale_t st2 = newlocale(LC_CTYPE_MASK, "en_US.UTF-8", st);
(gdb)
[Thread 13668.0x2158 exited with code 3221225477]
[Thread 13668.0x35d0 exited with code 3221225477]
[Thread 13668.0x2a7c exited with code 3221225477]

Program terminated with signal SIGTRAP, Trace/breakpoint trap.
The program no longer exists.
(gdb)

Tony

-- 
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019