Subject: NLS breakage on sparc64
To: None <tech-userlevel@NetBSD.ORG>
From: Martin Husemann <martin@duskware.de>
List: tech-userlevel
Date: 10/20/2001 18:18:22
I found a strange problem, and the locale stuff is confusing me + gdb, maybe
someone has any ideas offhand what happens here...

The attached program works as expected when compiled under sparc64 -current:

[/tmp] martin@setting-sun > ./dltest 
dll open: 0x40210400
symbol: 0x404e30f0
dll closed
[/tmp] martin@setting-sun > ./dltest crash
dll open: 0x40210400
calling setlocale(LC_CTYPE, "de_DE.ISO8859-1");
locale set.
symbol: 0x404e30f0
dll closed
[/tmp] martin@setting-sun > 

When the same program is compiled on 1.5.2 and the binary then run under
current, it crashes (inside the printf call following the setlocale):

[/tmp] martin@setting-sun > ./dltest crash
dll open: 0x40210400
calling setlocale(LC_CTYPE, "de_DE.ISO8859-1");
Segmentation fault (core dumped)

Other ports don't have this problem, but since gdb is heavily confused
too I'm a bit poking in the dark which change might have caused this.

Hints appreciated,

Martin

#include <stdio.h>
#include <locale.h>
#include <dlfcn.h>

int main(int argc, char ** argv) 
{
        void *sym, *dllHandle = dlopen("/usr/lib/libz.so", DL_LAZY);
        printf("dll open: %p\n", dllHandle);
        if (argc>1) {
            printf("calling setlocale(LC_CTYPE, \"de_DE.ISO8859-1\");\n");
            setlocale(LC_CTYPE, "de_DE.ISO8859-1");
            printf("locale set.\n");
        }
        sym = dlsym(dllHandle, "inflate_fast");
        printf("symbol: %p\n", sym);
        dlclose(dllHandle);
        printf("dll closed\n");
        return 0;
}