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=1.1 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 31B99BC6C for ; Wed, 31 Oct 2007 08:47:35 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAEvQJ0eFBoIFh2dsb2JhbACOZAIBCAop X-IronPort-AV: E=Sophos;i="4.21,350,1188770400"; d="scan'208";a="18791393" Received: from rabbit.math.nagoya-u.ac.jp ([133.6.130.5]) by mail4-smtp-sop.national.inria.fr with ESMTP; 31 Oct 2007 08:47:33 +0100 Received: from localhost (millas [172.16.30.29]) by rabbit.math.nagoya-u.ac.jp (8.12.11/3.7W) with ESMTP id l9V7lBql027429; Wed, 31 Oct 2007 16:47:11 +0900 (JST) Date: Wed, 31 Oct 2007 16:47:27 +0900 (JST) Message-Id: <20071031.164727.246512997.garrigue@math.nagoya-u.ac.jp> To: skaller@users.sourceforge.net Cc: angela.zhu@cs.rice.edu, caml-list@yquem.inria.fr Subject: Re: [Caml-list] How to prevent program from crashing From: Jacques Garrigue In-Reply-To: <1193813647.8355.57.camel@rosella.wigram> References: <1193807321.8355.10.camel@rosella.wigram> <1193813647.8355.57.camel@rosella.wigram> X-Mailer: Mew version 4.0.69 on Emacs 22.0.50 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii 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 bug:01 lablgtk:01 lablgtk:01 offs:98 sourceforge:01 From: skaller > > 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