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:
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:
iconv_t ic = iconv_open("UTF-8", "ISO-8859-1");
if (ic == (iconv_t)-1)
err(1, "iconv_open failed");
Save in `foo.c` and compile like this:
$ cc -static foo.c -o foo
foo: iconv_open failed: Invalid argument
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.
Created attachment 161413 [details]
add bug information to iconv manpage
Is somebody on this bug? It's annoying to debug.
Some workaround ideas:
1) let linking fail
2) don't write to stdout, some programms use this to communicate.
3) make the error message less cryptic. for example "dynamic linking Service unavailable"
4) add information to the manpage