iconv_open failure --- WAS: Re: scheduleWaitThread looping

Gabor Greif ggreif at gmail.com
Sun Feb 24 01:46:40 CET 2013


On 2/23/13, Stephen Paul Weber <singpolyma at singpolyma.net> wrote:
> Somebody claiming to be Gabor Greif wrote:
>>I have finally have a cross compiler building, but encounter a new
>>problem with a simple "Hello World" program not working.
>>
>>HeapProfTimer endlessly and nothing useful happens. Any idea what
>>could be wrong, or how I could tackle debugging this problem. The
>>native build of the same program with same compiler version (HEAD)
>>works well.
>
> This may be unrelated, but I've had a similar issue that I haven't finished
>
> debugging yet.
>
> Is the LANG environment variable set?  Trying running with LANG=""

Hi Stephen!

This did not help. But you pointed me to the right direction :-)

I observed that in each loop 'iconv_open' gets called, but returns a
failure (-1)

Breakpoint 1, 0x0fdac770 in iconv_open () from /lib/tls/libc.so.6
(gdb) p (char*)$r3
$1 = 0x3010401c "ANSI_X3.4-1968"
(gdb) p (char*)$r4
$2 = 0x30104008 "UTF-32BE"

(gdb) call iconv_open("ANSI_X3.4-1968","UTF-32BE")
$3 = -1
(gdb) call iconv_open("ASCII","ASCII")
$4 = 272079520
(gdb) call iconv_open("ASCII","UTF-32BE")
$5 = -1
(gdb) call iconv_open("ASCII","UTF-32")
$6 = -1
(gdb) call iconv_open("ASCII","UTF-8")
$7 = 272088200
(gdb) call iconv_open("ANSI_X3.4-1968","UTF-8")
$8 = 272120976

As you see my manual attempts to get a converter towards UTF-8 worked.

The main problem is that upon failure, an error with a message is
thrown, which restarts the scheduler loop again, but cannot
display any message because in order to do that it needs to open
iconv again... A veritable catch-22.

So all keeps looping and nothing happens.

Here is the relevant code from base/GHC/IO/Encoding/Iconv.hs:

newIConv from to rec fn =
  -- Assume charset names are ASCII
  withCAString from $ \ from_str ->
  withCAString to   $ \ to_str -> do
    iconvt <- throwErrnoIfMinus1 "mkTextEncoding" $ hs_iconv_open
to_str from_str
    let iclose = throwErrnoIfMinus1_ "Iconv.close" $ hs_iconv_close iconvt
    return BufferCodec{
                encode = fn iconvt,
                recover = rec,
                close  = iclose,
                -- iconv doesn't supply a way to save/restore the state
                getState = return (),
                setState = const $ return ()
                }


What is disturbing me, that this simple hello-world program used to
work a year ago, with no iconv-related problems at all, and I am
wondering what has changed since 7.5 and how to salvage the situation
now?

I am thankful for any suggestions,

cheers,

    Gabor


>
> --
> Stephen Paul Weber, @singpolyma
> See <http://singpolyma.net> for how I prefer to be contacted
> edition right joseph
>



More information about the ghc-devs mailing list