Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 06 Jan 2015 18:13:15 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 196567] iconv() function crashes with cryptic error message if linked statically
Message-ID:  <bug-196567-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D196567

            Bug ID: 196567
           Summary: iconv() function crashes with cryptic error message if
                    linked statically
           Product: Base System
           Version: 10.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs@FreeBSD.org
          Reporter: quintus@quintilianus.eu

Hi everyone,

I=E2=80=99ve been trying to link a program statically that calls the iconv(=
3) function
and was confronted with it printing the rather cryptic message "Service
unavailable" and immediately exiting the program. After some websearch, I f=
ound
this thread on the freebsd-current mailinglist:

*
https://docs.freebsd.org/cgi/getmsg.cgi?fetch=3D140017+0+archive/2013/freeb=
sd-current/20130825.freebsd-current
*
https://docs.freebsd.org/cgi/getmsg.cgi?fetch=3D177755+0+archive/2013/freeb=
sd-current/20130825.freebsd-current
*
https://docs.freebsd.org/cgi/getmsg.cgi?fetch=3D195390+0+archive/2013/freeb=
sd-current/20130825.freebsd-current

It appears nothing has happened since that thread, so I add it to the track=
er
now so it won=E2=80=99t get forgotten and because I just experienced that i=
ssue as
well.

Here=E2=80=99s the minimal example program from that ML thread to reproduce=
 the crash:

~~~~~~~~~~~~~~~~~~~~~~
int main(void)
{
        iconv_t ic =3D iconv_open("UTF-8", "ISO-8859-1");
        if (ic =3D=3D (iconv_t)-1)
                err(1, "iconv_open failed");
        iconv_close(ic);
        return 0;
}
~~~~~~~~~~~~~~~~~~~~~~

Save in `foo.c` and compile like this:

~~~~~~~~~~~~~~~~~~~~~~
$ cc -static foo.c -o foo
~~~~~~~~~~~~~~~~~~~~~~

Then run:

~~~~~~~~~~~~~~~~~~~~~~
$ ./foo
foo: iconv_open failed: Invalid argument
Service unavailable
~~~~~~~~~~~~~~~~~~~~~~

I can confirm this behaviour stil exists in FreeBSD 10.1-RELEASE. The above
example program still "works" (i.e. fails and demonstrates the problem).

Expected behaviour is to print a useful and understandable error message if=
 it
really isn=E2=80=99t possible to get iconv() to work in a statically linked=
 program.

Greetings,
Marvin

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-196567-8>