[Bug 196567] iconv() function crashes with cryptic error message if linked statically

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Tue Jan 6 20:03:51 UTC 2015


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=196567

            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 at FreeBSD.org
          Reporter: quintus at quintilianus.eu

Hi everyone,

I’ve 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 found
this thread on the freebsd-current mailinglist:

*
https://docs.freebsd.org/cgi/getmsg.cgi?fetch=140017+0+archive/2013/freebsd-current/20130825.freebsd-current
*
https://docs.freebsd.org/cgi/getmsg.cgi?fetch=177755+0+archive/2013/freebsd-current/20130825.freebsd-current
*
https://docs.freebsd.org/cgi/getmsg.cgi?fetch=195390+0+archive/2013/freebsd-current/20130825.freebsd-current

It appears nothing has happened since that thread, so I add it to the tracker
now so it won’t get forgotten and because I just experienced that issue as
well.

Here’s the minimal example program from that ML thread to reproduce the crash:

~~~~~~~~~~~~~~~~~~~~~~
int main(void)
{
        iconv_t ic = iconv_open("UTF-8", "ISO-8859-1");
        if (ic == (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’t possible to get iconv() to work in a statically linked program.

Greetings,
Marvin

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


More information about the freebsd-bugs mailing list