GHC static binaries with glibc-2.12?

Hi all, I recently upgraded my Arch Linux system to glibc 2.12 and static binaries compiled with GHC 6.12.3 all fail with the message "mkTextEncoding: invalid argument (Invalid argument)". This did not happen with glibc 2.11. Has anyone else had this problem? Does anyone have any advice for debugging it? Thanks, Alex

On 08/10/2010 03:23, Alexander Dunlap wrote:
I recently upgraded my Arch Linux system to glibc 2.12 and static binaries compiled with GHC 6.12.3 all fail with the message "mkTextEncoding: invalid argument (Invalid argument)". This did not happen with glibc 2.11. Has anyone else had this problem? Does anyone have any advice for debugging it?
Probably something to do with iconv. Doesn't iconv need to load its codec modules dynamically at runtime? Cheers, Simon

On Fri, Oct 8, 2010 at 12:46 AM, Simon Marlow
On 08/10/2010 03:23, Alexander Dunlap wrote:
I recently upgraded my Arch Linux system to glibc 2.12 and static binaries compiled with GHC 6.12.3 all fail with the message "mkTextEncoding: invalid argument (Invalid argument)". This did not happen with glibc 2.11. Has anyone else had this problem? Does anyone have any advice for debugging it?
Probably something to do with iconv. Doesn't iconv need to load its codec modules dynamically at runtime?
Cheers, Simon
Yes, it does, but strace seems to show that the program is looking in the right place for the iconv libraries. Is there some way to step through the code of a statically-linked program? I'm not sure how to proceed debugging a Haskell-originated error that only occurs with static linking (so I can't use the GHCi debugger). Alex

On 10/10/2010 05:22, Alexander Dunlap wrote:
On Fri, Oct 8, 2010 at 12:46 AM, Simon Marlow
wrote: On 08/10/2010 03:23, Alexander Dunlap wrote:
I recently upgraded my Arch Linux system to glibc 2.12 and static binaries compiled with GHC 6.12.3 all fail with the message "mkTextEncoding: invalid argument (Invalid argument)". This did not happen with glibc 2.11. Has anyone else had this problem? Does anyone have any advice for debugging it?
Probably something to do with iconv. Doesn't iconv need to load its codec modules dynamically at runtime?
Cheers, Simon
Yes, it does, but strace seems to show that the program is looking in the right place for the iconv libraries. Is there some way to step through the code of a statically-linked program? I'm not sure how to proceed debugging a Haskell-originated error that only occurs with static linking (so I can't use the GHCi debugger).
The error is almost certainly being returned by iconv(), which is called via this wrapper in base/cbits/iconv.c: size_t hs_iconv(iconv_t cd, const char* * inbuf, size_t * inbytesleft, char* * outbuf, size_t * outbytesleft) { // (void*) cast avoids a warning. Some iconvs use (const // char**inbuf), other use (char **inbuf). return iconv(cd, (void*)inbuf, inbytesleft, outbuf, outbytesleft); } you could run the program in gdb and set a breakpoint on hs_iconv, or iconv itself. Since it will be compiled without debugging information you'll have to poke around on the C stack yourself to find the arguments. Alternatively get a GHC build and instrument the code in libraries/base/GHC/IO/Encoding/IConv.hs to see what's going on. Cheers, Simon

On Mon, Oct 11, 2010 at 2:11 AM, Simon Marlow
On 10/10/2010 05:22, Alexander Dunlap wrote:
On Fri, Oct 8, 2010 at 12:46 AM, Simon Marlow
wrote: On 08/10/2010 03:23, Alexander Dunlap wrote:
I recently upgraded my Arch Linux system to glibc 2.12 and static binaries compiled with GHC 6.12.3 all fail with the message "mkTextEncoding: invalid argument (Invalid argument)". This did not happen with glibc 2.11. Has anyone else had this problem? Does anyone have any advice for debugging it?
Probably something to do with iconv. Doesn't iconv need to load its codec modules dynamically at runtime?
Cheers, Simon
Yes, it does, but strace seems to show that the program is looking in the right place for the iconv libraries. Is there some way to step through the code of a statically-linked program? I'm not sure how to proceed debugging a Haskell-originated error that only occurs with static linking (so I can't use the GHCi debugger).
The error is almost certainly being returned by iconv(), which is called via this wrapper in base/cbits/iconv.c:
size_t hs_iconv(iconv_t cd, const char* * inbuf, size_t * inbytesleft, char* * outbuf, size_t * outbytesleft) { // (void*) cast avoids a warning. Some iconvs use (const // char**inbuf), other use (char **inbuf). return iconv(cd, (void*)inbuf, inbytesleft, outbuf, outbytesleft); }
you could run the program in gdb and set a breakpoint on hs_iconv, or iconv itself. Since it will be compiled without debugging information you'll have to poke around on the C stack yourself to find the arguments.
Alternatively get a GHC build and instrument the code in libraries/base/GHC/IO/Encoding/IConv.hs to see what's going on.
Cheers, Simon
$ gdb ./main-static GNU gdb (GDB) 7.2 Copyright (C) 2010 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 "i686-pc-linux-gnu". For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from /home/alex/tmp/main-static...(no debugging symbols found)...done. (gdb) break iconv Breakpoint 1 at 0x80bbd66 (gdb) break hs_iconv Breakpoint 2 at 0x8065de6 (gdb) run Starting program: /home/alex/tmp/main-static [Thread debugging using libthread_db enabled] main-static: mkTextEncoding: invalid argument (Invalid argument) Program exited with code 01. (gdb) Does this indicate that the error is occurring before iconv is even called? Or do I have to do something else to make the breakpoint work. (Sorry, I'm not an expert with GDB.) Alex

On Wed, Oct 20, 2010 at 10:23:59PM -0700, Alexander Dunlap wrote:
On Mon, Oct 11, 2010 at 2:11 AM, Simon Marlow
wrote: On 10/10/2010 05:22, Alexander Dunlap wrote:
On Fri, Oct 8, 2010 at 12:46 AM, Simon Marlow
wrote: On 08/10/2010 03:23, Alexander Dunlap wrote:
I recently upgraded my Arch Linux system to glibc 2.12 and static binaries compiled with GHC 6.12.3 all fail with the message "mkTextEncoding: invalid argument (Invalid argument)". This did not happen with glibc 2.11. Has anyone else had this problem? Does anyone have any advice for debugging it?
Yes, it does, but strace seems to show that the program is looking in the right place for the iconv libraries. Is there some way to step through the code of a statically-linked program? I'm not sure how to proceed debugging a Haskell-originated error that only occurs with static linking (so I can't use the GHCi debugger).
The error is almost certainly being returned by iconv(), which is called via this wrapper in base/cbits/iconv.c:
size_t hs_iconv(iconv_t cd, return iconv(cd, (void*)inbuf, inbytesleft, outbuf, outbytesleft);
Does this indicate that the error is occurring before iconv is even called?
I suspect it's actually hs_iconv_open (which calls iconv_open) which gives the error. Thanks Ian

Am Freitag, 8. Oktober 2010, 04:23:48 schrieb Alexander Dunlap:
I recently upgraded my Arch Linux system to glibc 2.12 and static binaries compiled with GHC 6.12.3 all fail with the message "mkTextEncoding: invalid argument (Invalid argument)". This did not happen with glibc 2.11. Has anyone else had this problem? Does anyone have any advice for debugging it?
I had a similar problem with building ghc in the SUSE Build Service, but only for openSUSE 11.2 and 11.3 and not with a local build on my own machine. The solution was to require the openSUSE-package glibc-locale for build. I don't know much about arch packaging, but maybe you have a similar problem and need to install an additional package which contains the files below /usr/share/locale, too. Herbert
participants (4)
-
Alexander Dunlap
-
Herbert Graeber
-
Ian Lynagh
-
Simon Marlow