crash in newlocale()

Ken Brown kbrown@cornell.edu
Thu Aug 11 13:13:21 GMT 2022


On 8/10/2022 9:29 PM, Tony Cook wrote:
> While I get a SEGV from miniperl, a simple reproducer returns a
> SIGTRAP:
> 
> tony@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@enceladus ~/dev/perl/git
> $ gcc -onewlocale-test -g newlocale-test.c
> 
> tony@enceladus ~/dev/perl/git
> $ gdb ./newlocale-test.exe
> GNU gdb (GDB) (Cygwin 11.2-1) 11.2
[...]
> 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.

I can't explain the SIGTRAP (but you'll find a lot of information if you search 
the internet).  But I don't think it necessarily indicates a problem with 
newlocale.  What happens if you just run your test program normally, not under 
gdb?  It works fine for me:

$ ./newlocale-test.exe

$ echo $?
0

Ken


More information about the Cygwin mailing list