<div dir="ltr">In RHEL 5 system, libc-6, I&#39;m seeing the following strange phenomena<div><br></div><div>$ cat iconv_test.c</div><div><div>#include &lt;stdio.h&gt;</div><div>#include &lt;errno.h&gt;</div><div>#include &lt;fcntl.h&gt;</div>
<div>#include &lt;iconv.h&gt;</div><div><br></div><div>void iconv_test() {</div><div>  static int nr = 0;</div><div>  iconv_t iconv = iconv_open(&quot;MSCP949&quot;,&quot;UTF-8&quot;);</div><div>  //iconv_t iconv = iconv_open(&quot;UTF-16&quot;,&quot;UTF-8&quot;);</div>
<div>  if (iconv == (iconv_t)-1) {</div><div>    puts( &quot;can&#39;t initialize iconv&quot;);</div><div>  } else {</div><div>    puts( &quot;iconv open success!&quot; );</div><div>  }</div><div>  nr++;</div><div>}</div>
<div><br></div><div>int main(int argc,char **argv) {</div><div>  iconv_test();</div></div><div>  return 0;</div><div>}</div><div><br></div><div>$ gcc iconv_test.c</div><div>$ ./a.out</div><div>iconv open success!
</div><div>$ sudo su -</div><div># chown root:foo a.out</div><div># chmod 4555 a.out</div><div># su foo -</div><div>$ ./a.out</div><div>can&#39;t initialize iconv
</div><div>$ strace ./a.out 2&gt;/dev/null</div><div>iconv open success!
</div><div><br></div><div><br></div><div>iconv_open on UTF-16 to UTF-8 succeeds!</div><div>This phenomena doesn&#39;t happen in recent Ubuntu.</div><div><br></div><div>I&#39;m not familiar with the inner workings of iconv, but stracing a good iconv run reveals it dlopen so files according to the chosen encodings, maybe it&#39;s related.</div>
<div><br></div><div>1) I&#39;ll be glad for any thoughts or ideas how to debug this issue, other than downloading the libc source rpm, compiling it, LD_PRELOAD, and hope the problem will be recreated.</div><div><br></div>
<div>2) If someone can test this on a RHEL-5 machine, and report if it happens to him too, it could be helpful.</div><div><br></div><div>Thanks,</div></div>