bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnubg] seg fault when using the german lang.


From: Jim Segrave
Subject: Re: [Bug-gnubg] seg fault when using the german lang.
Date: Sun, 3 Aug 2003 19:56:27 +0200
User-agent: Mutt/1.2.5.1i

On Sun 03 Aug 2003 (16:58 +0200), Achim wrote:
> Am Son, 2003-08-03 um 16.22 schrieb Martin Janke:
> > On Sun, 2003-08-03 at 16:14, Martin Janke wrote:
> > > On Sun, 2003-08-03 at 12:11, Achim Mueller wrote:
> > > > Am Son, 2003-08-03 um 09.24 schrieb Martin Janke:
> > > > > On Sat, 2003-08-02 at 20:35, Achim Mueller wrote:
> > > > > > Hi folks,
> > > > > > 
> > > > > > I just recognized, that I get a seg fault when doing a move using 
> > > > > > the
> > > > > > german version of gnubg (only gui, non-gui works). 
> > > > > >
> > > > > No problem here (on Gentoo Linux).
> > > > > 
> > > > 
> > > > Did you use the cvs from yesterday?
> > > 
> > > No, it was in the CVS from 27th July. After updating an re-compiling I
> > > now have the same problem. Sometimes at the first move, sometimes later.
> > > Attached the back trace (not sure whether that helps).
> > 
> > It seems to crash whenever you try to move a checker in your opponents home 
> > board.
> 
> There must be something worng with one of the 100 translations I did on
> friday afternoon ...

OK - I sort of know what the problem is, I don't have an easy answer.
For reasons unknown to me, to set my locale for Germany, I need to do
export LANG=de_DE.ISO8859-1
  (note that that there is no '-' between the ISO and the 8859). 

iconv_open does not know how to do a conversion to/from UTF-8 and
ISO8859-1. It does know how to convert between UTF-8 and ISO-8859-1

You get a segv, because Convert() in gnubg attempts the iconv_open()
which fails because it doesn't recognise the character set. It then
tries to output an error message about not being able to do
iconv_open. But that involves calling Convert again. The call is tail
recursive, so you don't get a huge number of stack frames, just a
stack descending until you SEGV. One problem needing solving is to
output the error message without attempting this conversion - maybe
forcing szTerminalCharset to "ISO-8859-1" before reporting the error.

I made a hack fix to substitue a pointer to "ISO-8859-1" for a source
or destination pointer of "ISO8859-1" in Convert() and that works, but
that can't be correct. 

More to the point, I don't know how this worked before or how it works
for other users (for example, setting LANG=da_DK.ISO8859-1 crashes in
the same way, setting LANG=da_DK.ISO-8859-1 doesn't crash, but also
complains that the locale is not recognised (I do get Danish output
though).

As a side note, the code in COnvert() in gnubg.c is very suspect:

iconv_t is a pointer to void (at least under FreeBSD)

  id = iconv_open ( szDestCharset, szSourceCharset );

  if ( id < 0 ) {
    outputerr ( "iconv_open" );
    return strdup ( sz );
  }

This code is ill-defined and should be:

  if ( id == (iconv_t) -1 ) {
    outputerr ( "iconv_open" );
    return strdup ( sz );
  }


-- 
Jim Segrave           address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]