Version française
Home     About     Download     Resources     Contact us    
Browse thread
How to prevent program from crashing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] How to prevent program from crashing
From: skaller <skaller@users.sourceforge.net>
> > Following is the message I got after the crashing:
> > 
> > 
> > ************************************************************************ 
> > ************************
> > (acumen:4063): Gtk-CRITICAL **: _gtk_text_line_char_locate: assertion  
> > `char_offs
> > et >= 0' failed
> > 
> > Gtk-ERROR **: Char offset -1 is off the end of the line
> > aborting...
> > Abort trap
> 
> Yeah, this is an abort from a failed assertion in C,
> so it isn't an Ocaml exception.
> 
> I don't know how GTK handles this, that is, whether there is
> a way to register an error handler. You should ask
> Jacques Garrigue that.. hmmm. no I'll post this to the list
> because this is quite an interesting issue.
> 
> It would appear that this line in your code, which calls the
> GTK binding:
> 
>  let appp = program2#buffer#get_text()
> 
> is the source of the problem, and that would be a bug in the Ocaml
> library, not your code. Even if the buffer is empty, at least Ocaml
> the library should handle this.

If this is intended as a bug report, this is a poor one indeed.
We need at least the version numbers for both Gtk and LablGTK2, and
the actual code...

As it is, buffer#get_text () seems to work perfectly with empty
buffers, with the latest version of LablGTK2, and Gtk-2.6.10.

Independently of that, text iterators can be very tricky to use
manually. LablGTK attempts at catching errors, but Gtk sometimes
crashes after the exception is caught... So better to be sure to make
no error.

Jacques Garrigue