Subject: lib/22023: multiple iconv_open/close fails
To: None <>
From: Johan Danielsson <>
List: netbsd-bugs
Date: 06/30/2003 23:15:36
>Number:         22023
>Category:       lib
>Synopsis:       multiple iconv_open/close fails
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 30 21:16:00 UTC 2003
>Originator:     Johan Danielsson
>Release:        NetBSD 1.6T
	<organization of PR author (multiple lines)>
	<The following information is extracted from your kernel. Please>
	<append output of "ldd", "ident" where relevant (multiple lines).>
System: NetBSD 1.6T NetBSD 1.6T (BLUBB) #531: Thu May 29 13:09:25 CEST 2003 i386
Architecture: i386
Machine: i386


In the following program, the last iconv_open returns -1.  At one
point it worked with an iconv() on a string of proper length before
the two iconv_close() calls, but I can't repeat this anymore.  This
smells a bit like memory corruption.

While this code may seem strange, there are applications that do
things like this. It works with GNU libiconv and the iconv found in
AIX 4.3 (those were the only ones I could find that supported UTF-8).

#include <stdio.h>
#include <iconv.h>

    iconv_t a, b;

    a = iconv_open("UTF-8", "UTF-8");
    printf("%p\n", a);
    if(a == (iconv_t)-1)
    b = iconv_open("ISO8859-1", "UTF-8");
    printf("%p\n", b);
    if(b == (iconv_t)-1)


    b = iconv_open("ISO8859-1", "UTF-8");
    printf("%p\n", b);


$ gcc test.c 
$ ./a.out 


I have no idea. The citrus code is a too complicated for me, epecially
since my gdb doesn't like to single step. I got as far as open_dsts()
in citrus_iconv_std.c before giving up.
 	<Please check that the above is correct for the bug being reported,>
 	<and append source date of snapshot, if applicable (one line).>