Re: Segfault: ?


Subject: Re: Segfault: ?
From: Vlad Harchev (hvv@hippo.ru)
Date: Wed Nov 15 2000 - 06:04:58 CST


On Wed, 15 Nov 2000, ha shao wrote:

> On Wed, Nov 15, 2000 at 01:48:06PM +0400, hvv@hippo.ru wrote:
> >
> > May be glibc is buggy in MDK as usual?
> >
> > I think we can use the following workaround for this problem:
> > instead of
> > iconv(handle,NULL,NULL,NULL,NULL);
> > everywhere use
> > iconv_reset(handle)
> > where it's defined as follows:
> >
> > void iconv_reset(iconv_t cd)
> > {
> > if (XAP_EncodingManager::instance->cjk_locale())
> > iconv(cd,NULL,NULL,NULL,NULL);
> > }
> >
> > since shift state (and its resetting) is meaningful only on multibyte locales
> > such as CJK ones.
> >
>
> Yes, it is just a work around.
>
> But why iconv(cd,NULL,NULL,NULL,NULL) is called before the return state
> of the previous iconv is checked?

 You mean, that it's OK to crash if you've never used that iconv descriptor?
 
> I was talking about the call in try_UToC(). If
> iconv(cd,NULL,NULL,NULL,NULL) is needed, why
> not iconv(cd, NULL, NULL, &optr, &obuflen)?
> It seems iconv(cd,NULL,NULL,NULL,NULL) only reset
> the state of 'cd' but that is useless if iconv
> is only called once in try_UToC which transfer
> ucs2 to other codeset.

 That iconv descriptor is shared - i.e. it's never freed. Since try_UToC is
called from a lot of various places, I though that it would be wise to reset
state to avoid problems with mb encodings.
 
> GB2312 don't use shift state, I don't really know this.

 It seems that some CJK encodings have shift state.

>

 Best regards,
  -Vlad



This archive was generated by hypermail 2b25 : Wed Nov 15 2000 - 06:25:10 CST