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.0 required=5.0 tests=HTML_MESSAGE 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 9D4F2BC6B for ; Wed, 31 Oct 2007 05:29:30 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKahJ0eAKs4Fnmdsb2JhbACCcotzAgEBBwQGERiBEw X-IronPort-AV: E=Sophos;i="4.21,349,1188770400"; d="scan'208,217";a="18788462" Received: from netscaler2.rice.edu (HELO mh1.mail.rice.edu) ([128.42.206.5]) by mail4-smtp-sop.national.inria.fr with ESMTP; 31 Oct 2007 05:29:26 +0100 Received: from mh1.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh1.mail.rice.edu (Postfix) with ESMTP id AE2EE3851DD for ; Tue, 30 Oct 2007 23:29:25 -0500 (CDT) X-Virus-Scanned: by amavis-2.4.4 at mh1.mail.rice.edu Received: from mh1.mail.rice.edu ([127.0.0.1]) by mh1.mail.rice.edu (mh1.mail.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nzZsSzlaXhtx for ; Tue, 30 Oct 2007 23:29:25 -0500 (CDT) Received: from [10.194.94.87] (unknown [10.194.94.87]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mh1.mail.rice.edu (Postfix) with ESMTP id 859E8385111 for ; Tue, 30 Oct 2007 23:29:25 -0500 (CDT) Mime-Version: 1.0 (Apple Message framework v752.3) To: caml-list@yquem.inria.fr Message-Id: Content-Type: multipart/alternative; boundary=Apple-Mail-63-749395701 From: Angela Zhu Subject: How to prevent program from crashing Date: Tue, 30 Oct 2007 23:29:20 -0500 X-Mailer: Apple Mail (2.752.3) X-Spam: no; 0.00; ocaml:01 syntax:01 syntax:01 semi-colon:01 ocaml:01 semi-colon:01 angela:98 angela:98 seems:03 seems:03 crashes:03 crashes:03 gui:03 gui:03 zhu:04 --Apple-Mail-63-749395701 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Dear all, I am trying to develop a new language with GUI using OCaml. However, the language seems to be not very stable. If a small syntax error in the program(written in this new language) happens, it can through an error message. If the syntax error is kind of critical, (e.g., a semi-colon is missed at the end of a line, or a keyword is mis-spelled) Then the whole GUI of the language crashes. Does anyone else have ever encountered similar problem? Or can anyone give me a hint on how to prevent this? Thanks a lot! Angela ------------------------------------------ Dept. of CS, Rice Unitersity http://www.cs.rice.edu/~yz2/ ------------------------------------------ --Apple-Mail-63-749395701 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1 Dear all,

I am trying to=A0develop a = new language with GUI using OCaml.
However, the language seems = to be not very stable.

If a small syntax error in = the program(written in this new language) happens,
it can = through an error message.
If the syntax error is kind of = critical,=A0
(e.g., a semi-colon is missed at the end of a = line,=A0
=A0or a keyword is mis-spelled)
Then the = whole GUI of the language crashes.

Does anyone else have ever = encountered similar problem?
Or can anyone give me a hint on = how to prevent this?

Thanks a = lot!
Angela
Dept. of CS, Rice Unitersity
http://www.cs.rice.edu/~yz2/




= --Apple-Mail-63-749395701-- 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 91438BC6B for ; Wed, 31 Oct 2007 06:09:37 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAEKrJ0fLENaHnmdsb2JhbACOZQIBAQcEBhEY X-IronPort-AV: E=Sophos;i="4.21,349,1188770400"; d="scan'208";a="3757751" Received: from ipmail03.adl2.internode.on.net ([203.16.214.135]) by mail2-smtp-roc.national.inria.fr with ESMTP; 31 Oct 2007 06:09:33 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAJ6pJ0d5LGK+/2dsb2JhbAAM X-IronPort-AV: E=Sophos;i="4.21,349,1188743400"; d="scan'208";a="178257439" 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 15:38:43 +1030 Subject: Re: [Caml-list] How to prevent program from crashing From: skaller To: Angela Zhu Cc: caml-list@yquem.inria.fr In-Reply-To: References: Content-Type: text/plain Date: Wed, 31 Oct 2007 16:08:41 +1100 Message-Id: <1193807321.8355.10.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; syntax:01 ocaml:01 hashtbl:01 endline:01 hashtbl:01 angela:98 sourceforge:01 wrote:01 exception:01 caml-list:01 functions:01 functions:01 exceptions:01 handles:03 crashes:03 On Tue, 2007-10-30 at 23:29 -0500, Angela Zhu wrote: > > If a small syntax error in the program(written in this new language) > happens, [] > Then the whole GUI of the language crashes. You need to isolate the GUI part of your program from the part that handles errors. In particular you should be careful to undo the unfortunate tendency of various Ocaml functions to throw exceptions, and thereby 'crash' your program if you fail to handle them. For example write: let hfind msg table key = try Hashtbl.find table key with Not_found -> print_endline ("Hashtbl.find failed in " ^ msg); abort() ;; let maybe_hfind table key = try Some (Hashtbl.find table key) with Not_found -> None ;; and use one or other of these functions instead of the raw Hashtbl.find function, which can throw an exception you forget to catch and crash your program without a clear reason. Here 'hfind' will still crash your program, but hopefully help find your programming error, whereas the maybe_hfind function will never fail and uses the type system to force you to check for errors and handle them. -- John Skaller Felix, successor to C++: http://felix.sf.net 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 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.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id EF48FBC6B for ; Wed, 31 Oct 2007 08:13:52 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAK/HJ0eAKs4Fnmdsb2JhbACOZAIBAQcEBhEY X-IronPort-AV: E=Sophos;i="4.21,350,1188770400"; d="scan'208";a="5306428" Received: from netscaler2.rice.edu (HELO mh1.mail.rice.edu) ([128.42.206.5]) by mail3-smtp-sop.national.inria.fr with ESMTP; 31 Oct 2007 08:13:50 +0100 Received: from mh1.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh1.mail.rice.edu (Postfix) with ESMTP id A481938588D; Wed, 31 Oct 2007 02:13:48 -0500 (CDT) X-Virus-Scanned: by amavis-2.4.4 at mh1.mail.rice.edu Received: from mh1.mail.rice.edu ([127.0.0.1]) by mh1.mail.rice.edu (mh1.mail.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VvgxyqZTHkyb; Wed, 31 Oct 2007 02:13:48 -0500 (CDT) Received: from [192.168.1.102] (c-98-195-25-217.hsd1.tx.comcast.net [98.195.25.217]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mh1.mail.rice.edu (Postfix) with ESMTP id 6E11A38580A; Wed, 31 Oct 2007 02:13:48 -0500 (CDT) In-Reply-To: <1193813647.8355.57.camel@rosella.wigram> References: <1193807321.8355.10.camel@rosella.wigram> <1193813647.8355.57.camel@rosella.wigram> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <51DDF855-CE58-4737-B8FB-31E1C01F4D62@cs.rice.edu> Cc: caml-list@yquem.inria.fr Content-Transfer-Encoding: 7bit From: Angela Zhu Subject: Re: Re: Re:Re: [Caml-list] How to prevent program from crashing Date: Wed, 31 Oct 2007 02:13:43 -0500 To: skaller X-Mailer: Apple Mail (2.752.3) X-Spam: no; 0.00; assertion:01 ocaml:01 gtk:01 hmmm:01 gtk:01 buffer:01 bug:01 ocaml:01 buffer:01 angela:98 angela:98 exception:01 caml-list:01 binding:02 garrigue:03 > > 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. > Thank you very much for your attention. I wish this can be solved any way. :( Best regards, Angela ------------------------------------------ Dept. of CS, Rice Unitersity http://www.cs.rice.edu/~yz2/ ------------------------------------------ > > 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 > > 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 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 7435CBC6C for ; Wed, 31 Oct 2007 10:31:12 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAG7oJ0fLENaHnmdsb2JhbACOYwIBAQcEBhEY X-IronPort-AV: E=Sophos;i="4.21,350,1188770400"; d="scan'208";a="3762947" Received: from ipmail03.adl2.internode.on.net ([203.16.214.135]) by mail2-smtp-roc.national.inria.fr with ESMTP; 31 Oct 2007 10:31:11 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAGPlJ0d5LGK+Wmdsb2JhbAAMjk0BIA X-IronPort-AV: E=Sophos;i="4.21,350,1188743400"; d="scan'208";a="178413066" 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 20:01:07 +1030 Subject: Re: [Caml-list] How to prevent program from crashing From: skaller To: Jacques Garrigue Cc: caml-list@yquem.inria.fr In-Reply-To: <20071031.164727.246512997.garrigue@math.nagoya-u.ac.jp> References: <1193807321.8355.10.camel@rosella.wigram> <1193813647.8355.57.camel@rosella.wigram> <20071031.164727.246512997.garrigue@math.nagoya-u.ac.jp> Content-Type: text/plain Date: Wed, 31 Oct 2007 20:31:07 +1100 Message-Id: <1193823067.5879.31.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; gtk:01 buffer:01 bug:01 bug:01 ocaml:01 sourceforge:01 sourceforge:01 wrote:01 caml-list:01 binding:02 figuring:02 garrigue:03 jacques:03 let:03 wed:06 On Wed, 2007-10-31 at 16:47 +0900, Jacques Garrigue wrote: > From: skaller > > It would appear that this line in your code, which calls the > > GTK binding: > > > > let appp = program2#buffer#get_text() > If this is intended as a bug report, this is a poor one indeed. No, it isn't a bug report! It's a general request for more information, maybe some help figuring out how this could happen? Could you cause this with Ocaml code? -- John Skaller Felix, successor to C++: http://felix.sf.net