From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 080E3BC6B for ; Wed, 31 Oct 2007 07:54:13 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAACvDJ0fLENaHnmdsb2JhbACOZQIBAQcEBhEY X-IronPort-AV: E=Sophos;i="4.21,350,1188770400"; d="scan'208";a="3864294" Received: from ipmail03.adl2.internode.on.net ([203.16.214.135]) by mail1-smtp-roc.national.inria.fr with ESMTP; 31 Oct 2007 07:54:11 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAADrCJ0d5LGK+/2dsb2JhbAAM X-IronPort-AV: E=Sophos;i="4.21,350,1188743400"; d="scan'208";a="178323411" Received: from ppp121-44-98-190.lns10.syd6.internode.on.net (HELO [192.168.1.201]) ([121.44.98.190]) by ipmail03.adl2.internode.on.net with ESMTP; 31 Oct 2007 17:24:09 +1030 Subject: Re: Re:Re: [Caml-list] How to prevent program from crashing From: skaller To: Angela Zhu Cc: caml In-Reply-To: References: <1193807321.8355.10.camel@rosella.wigram> Content-Type: text/plain Date: Wed, 31 Oct 2007 17:54:07 +1100 Message-Id: <1193813647.8355.57.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; gtk:01 assertion:01 assertion:01 ocaml:01 gtk:01 hmmm:01 buffer:01 bug:01 ocaml:01 buffer:01 angela:98 offs:98 sourceforge:01 char:01 char:01 On Wed, 2007-10-31 at 00:52 -0500, Angela Zhu wrote: > And I am sure the whole program and GUI crashes when function > "resetState2_4openFile" > is called. > I tried to catch the exception, but seems that it doesn't work. > > 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. -- John Skaller Felix, successor to C++: http://felix.sf.net