Subject: Re: strange setlocale() issue
To: Markus Illenseer <email@example.com>
From: Greywolf <firstname.lastname@example.org>
Date: 10/13/2003 14:52:06
Thus spake Markus Illenseer ("MI> ") sometime Today...
MI> > Hmmm, I get a SIGSEGV on this one.
MI> How do you know?
rivendell 540: cat foo.c
const char *foo = "bar";
if( NULL == setlocale(LC_ALL, "zh_TW.eucTW") )
/* yes, I know, the 2nd argument should not be NULL */
printf("error! locale is: %s\n", setlocale(LC_ALL, NULL));
printf("OK %s\n", foo);
rivendell 541: cc foo.c -o foo
rivendell 542: ./foo
Segmentation fault (core dumped)
I'd say that's a pretty good indication.
MI> > A gdb trace gets nothing? What if you single-step through, where's it
MI> > get lost?
MI> Nothing -- unless I should do more than a simple "run". How do I do
MI> this single-step trace?
rivendell 543: cc -g foo.c -o foo
rivendell 544: gdb foo
GNU gdb 5.3nb1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386--netbsdelf"...
(gdb) b main
Breakpoint 1 at 0x804881c: file foo.c, line 5.
Starting program: /tmp/foo
Breakpoint 1, main () at foo.c:5
5 const char *foo = "bar";
7 if( NULL == setlocale(LC_ALL, "zh_TW.eucTW") )
Program received signal SIGSEGV, Segmentation fault.
0x480dea04 in vfprintf_unlocked () from /usr/lib/libc.so.12
MI> Markus Illenseer
[and you don't even have to type 's' after the first time -- just hit
return, and it will repeat the last command you gave it.]
NetBSD: Resistance is futile! You will be supported.