caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* exception not registered.Abandon
@ 2010-03-13 16:42 Florent Monnier
  2010-03-13 17:38 ` [Caml-list] " Richard Jones
  0 siblings, 1 reply; 8+ messages in thread
From: Florent Monnier @ 2010-03-13 16:42 UTC (permalink / raw)
  To: caml-list

Hi,
I have compiled a program using the native compiler, then when I run the 
executable I get this error message:

exception not registered.Abandon

Searching Google I don't find anything about this error message.
How should I interpret it?

-- 
Thanks


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] exception not registered.Abandon
  2010-03-13 16:42 exception not registered.Abandon Florent Monnier
@ 2010-03-13 17:38 ` Richard Jones
  2010-03-13 18:36   ` Florent Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Jones @ 2010-03-13 17:38 UTC (permalink / raw)
  To: Florent Monnier; +Cc: caml-list

On Sat, Mar 13, 2010 at 05:42:25PM +0100, Florent Monnier wrote:
> I have compiled a program using the native compiler, then when I run the 
> executable I get this error message:
> 
> exception not registered.Abandon
> 
> Searching Google I don't find anything about this error message.
> How should I interpret it?

Is the program linked to C code (apart from stdlib, I mean)?

AFAICT, no part of that message occurs in the OCaml codebase, although
my checked out version is a few months old now.

Rich.

-- 
Richard Jones
Red Hat


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] exception not registered.Abandon
  2010-03-13 17:38 ` [Caml-list] " Richard Jones
@ 2010-03-13 18:36   ` Florent Monnier
  2010-03-13 18:50     ` Adrien
  2010-03-13 18:55     ` Richard Jones
  0 siblings, 2 replies; 8+ messages in thread
From: Florent Monnier @ 2010-03-13 18:36 UTC (permalink / raw)
  To: caml-list

> > I have compiled a program using the native compiler, then when I run the
> > executable I get this error message:
> >
> > exception not registered.Abandon
> >
> > Searching Google I don't find anything about this error message.
> > How should I interpret it?
> 
> Is the program linked to C code (apart from stdlib, I mean)?

Yes it is.
It's linked with OpenGL (only the GL lib, no GLU or anything esle) and SDL 
(through ocaml-sdl)

It's a program that I try to switch the windowing part from Glut to SDL.
With Glut it works alright.

Also I've just seen that running in the interpreted mode instead of native 
code the program does run without any problem.

Do these additional informations give you any clue?

-- 
Thanks


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] exception not registered.Abandon
  2010-03-13 18:36   ` Florent Monnier
@ 2010-03-13 18:50     ` Adrien
  2010-03-13 18:55     ` Richard Jones
  1 sibling, 0 replies; 8+ messages in thread
From: Adrien @ 2010-03-13 18:50 UTC (permalink / raw)
  Cc: caml-list

On 13/03/2010, Florent Monnier <monnier.florent@gmail.com> wrote:
>> > I have compiled a program using the native compiler, then when I run the
>> > executable I get this error message:
>> >
>> > exception not registered.Abandon
>> >
>> > Searching Google I don't find anything about this error message.
>> > How should I interpret it?
>>
>> Is the program linked to C code (apart from stdlib, I mean)?
>
> Yes it is.
> It's linked with OpenGL (only the GL lib, no GLU or anything esle) and SDL
> (through ocaml-sdl)
>
> It's a program that I try to switch the windowing part from Glut to SDL.
> With Glut it works alright.
>
> Also I've just seen that running in the interpreted mode instead of native
> code the program does run without any problem.
>
> Do these additional informations give you any clue?
>

FWIW, I've quickly grep'ed for 'exception not registered' in my ocaml
install (which is fairly big) and all the results I got came from sdl
stubs : sdl{stub,mixerstub,loaderstub}.{so,a}.

 ---

Adrien Nader


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] exception not registered.Abandon
  2010-03-13 18:36   ` Florent Monnier
  2010-03-13 18:50     ` Adrien
@ 2010-03-13 18:55     ` Richard Jones
  2010-03-13 18:57       ` Richard Jones
  2010-03-13 19:33       ` Florent Monnier
  1 sibling, 2 replies; 8+ messages in thread
From: Richard Jones @ 2010-03-13 18:55 UTC (permalink / raw)
  To: Florent Monnier; +Cc: caml-list

On Sat, Mar 13, 2010 at 07:36:16PM +0100, Florent Monnier wrote:
> > > I have compiled a program using the native compiler, then when I run the
> > > executable I get this error message:
> > >
> > > exception not registered.Abandon
> > >
> > > Searching Google I don't find anything about this error message.
> > > How should I interpret it?
> > 
> > Is the program linked to C code (apart from stdlib, I mean)?
> 
> Yes it is.
> It's linked with OpenGL (only the GL lib, no GLU or anything esle) and SDL 
> (through ocaml-sdl)
> 
> It's a program that I try to switch the windowing part from Glut to SDL.
> With Glut it works alright.
> 
> Also I've just seen that running in the interpreted mode instead of native 
> code the program does run without any problem.
> 
> Do these additional informations give you any clue?

As Adrian said, it's from ocaml-SDL.  It's from one of several
functions which look like this:

 static void
 sdlloader_raise_exception (char *msg)
 {
   static value *loader_exn = NULL;
   if(! loader_exn){
     loader_exn = caml_named_value("SDLloader_exception");
     if(! loader_exn) {
       fprintf(stderr, "exception not registered.");
       abort();
     }
   }
   raise_with_string(*loader_exn, msg);
 }

Essentially you have to register OCaml exceptions before you can call
them from C, so it sounds like you're not calling some sort of SDL
"init" function (or calling it too late in your program).  Or possibly
there is a bug in the ocaml-SDL bindings.

Rich.

-- 
Richard Jones
Red Hat


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] exception not registered.Abandon
  2010-03-13 18:55     ` Richard Jones
@ 2010-03-13 18:57       ` Richard Jones
  2010-03-13 19:33       ` Florent Monnier
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Jones @ 2010-03-13 18:57 UTC (permalink / raw)
  To: Florent Monnier; +Cc: caml-list

On Sat, Mar 13, 2010 at 06:55:37PM +0000, Richard Jones wrote:
> Essentially you have to register OCaml exceptions before you can call
> them from C, so it sounds like you're not calling some sort of SDL
> "init" function (or calling it too late in your program).  Or possibly
> there is a bug in the ocaml-SDL bindings.

For example, is 'sdlloader.cmxa' linked into your program?  There are
others that might have to be linked in too -- see the META file or
just use ocamlfind.

Rich.

-- 
Richard Jones
Red Hat


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] exception not registered.Abandon
  2010-03-13 18:55     ` Richard Jones
  2010-03-13 18:57       ` Richard Jones
@ 2010-03-13 19:33       ` Florent Monnier
  2010-03-15  9:13         ` Olivier Andrieu
  1 sibling, 1 reply; 8+ messages in thread
From: Florent Monnier @ 2010-03-13 19:33 UTC (permalink / raw)
  To: caml-list

Le samedi 13 mars 2010 19:55:37, vous avez écrit :
> On Sat, Mar 13, 2010 at 07:36:16PM +0100, Florent Monnier wrote:
> > > > I have compiled a program using the native compiler, then when I run
> > > > the executable I get this error message:
> > > >
> > > > exception not registered.Abandon
> > > >
> > > > Searching Google I don't find anything about this error message.
> > > > How should I interpret it?
> > >
> > > Is the program linked to C code (apart from stdlib, I mean)?
> >
> > Yes it is.
> > It's linked with OpenGL (only the GL lib, no GLU or anything esle) and
> > SDL (through ocaml-sdl)
> >
> > It's a program that I try to switch the windowing part from Glut to SDL.
> > With Glut it works alright.
> >
> > Also I've just seen that running in the interpreted mode instead of
> > native code the program does run without any problem.
> >
> > Do these additional informations give you any clue?
> 
> As Adrian said, it's from ocaml-SDL.  It's from one of several
> functions which look like this:
> 
>  static void
>  sdlloader_raise_exception (char *msg)
>  {
>    static value *loader_exn = NULL;
>    if(! loader_exn){
>      loader_exn = caml_named_value("SDLloader_exception");
>      if(! loader_exn) {
>        fprintf(stderr, "exception not registered.");
>        abort();
>      }
>    }
>    raise_with_string(*loader_exn, msg);
>  }
> 
> Essentially you have to register OCaml exceptions before you can call
> them from C, so it sounds like you're not calling some sort of SDL
> "init" function (or calling it too late in your program).  Or possibly
> there is a bug in the ocaml-SDL bindings.

In the source of the sdlvideo.ml module there is:

exception Video_exn of string
let _ =
  Callback.register_exception "SDLvideo2_exception" (Video_exn "")

it seems for some reason that this code is not executed, because if I add at 
the beginning of my program (not in sdl source):

let () =
  (* notice the exception is prefixed with the name of the sdl module *)
  Callback.register_exception "SDLvideo2_exception" (Sdlvideo.Video_exn "");
;;

then I get the correct exception.
I don't understand what the bug is.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] exception not registered.Abandon
  2010-03-13 19:33       ` Florent Monnier
@ 2010-03-15  9:13         ` Olivier Andrieu
  0 siblings, 0 replies; 8+ messages in thread
From: Olivier Andrieu @ 2010-03-15  9:13 UTC (permalink / raw)
  To: Florent Monnier; +Cc: caml-list

On Sat, Mar 13, 2010 at 20:33, Florent Monnier
<monnier.florent@gmail.com> wrote:
> Le samedi 13 mars 2010 19:55:37, vous avez écrit :
>> On Sat, Mar 13, 2010 at 07:36:16PM +0100, Florent Monnier wrote:
>> > > > I have compiled a program using the native compiler, then when I run
>> > > > the executable I get this error message:
>> > > >
>> > > > exception not registered.Abandon
>> > > >
>> > > > Searching Google I don't find anything about this error message.
>> > > > How should I interpret it?
>> > >
>> > > Is the program linked to C code (apart from stdlib, I mean)?
>> >
>> > Yes it is.
>> > It's linked with OpenGL (only the GL lib, no GLU or anything esle) and
>> > SDL (through ocaml-sdl)
>> >
>> > It's a program that I try to switch the windowing part from Glut to SDL.
>> > With Glut it works alright.
>> >
>> > Also I've just seen that running in the interpreted mode instead of
>> > native code the program does run without any problem.
>> >
>> > Do these additional informations give you any clue?
>>
>> As Adrian said, it's from ocaml-SDL.  It's from one of several
>> functions which look like this:
>>
>>  static void
>>  sdlloader_raise_exception (char *msg)
>>  {
>>    static value *loader_exn = NULL;
>>    if(! loader_exn){
>>      loader_exn = caml_named_value("SDLloader_exception");
>>      if(! loader_exn) {
>>        fprintf(stderr, "exception not registered.");
>>        abort();
>>      }
>>    }
>>    raise_with_string(*loader_exn, msg);
>>  }
>>
>> Essentially you have to register OCaml exceptions before you can call
>> them from C, so it sounds like you're not calling some sort of SDL
>> "init" function (or calling it too late in your program).  Or possibly
>> there is a bug in the ocaml-SDL bindings.
>
> In the source of the sdlvideo.ml module there is:
>
> exception Video_exn of string
> let _ =
>  Callback.register_exception "SDLvideo2_exception" (Video_exn "")
>
> it seems for some reason that this code is not executed, because if I add at
> the beginning of my program (not in sdl source):
>
> let () =
>  (* notice the exception is prefixed with the name of the sdl module *)
>  Callback.register_exception "SDLvideo2_exception" (Sdlvideo.Video_exn "");
> ;;
>
> then I get the correct exception.
> I don't understand what the bug is.


It's (I think) the usual problem with library bindings where the
functions in the .mli are externals.
When your code contains only calls to externals of the module
(Sdlvideo), only the C part is linked in and not caml part (the .cmo).
The problem is that the important Callback.register_exception call is
in the caml part.

Solution: reference somewhere in your code a function that's declared
as "val" in the sdlvideo.mli.

cf. http://caml.inria.fr/mantis/view.php?id=4166 for instance

-- 
  Olivier


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-03-15  9:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-13 16:42 exception not registered.Abandon Florent Monnier
2010-03-13 17:38 ` [Caml-list] " Richard Jones
2010-03-13 18:36   ` Florent Monnier
2010-03-13 18:50     ` Adrien
2010-03-13 18:55     ` Richard Jones
2010-03-13 18:57       ` Richard Jones
2010-03-13 19:33       ` Florent Monnier
2010-03-15  9:13         ` Olivier Andrieu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).