[ocaml-ctypes] Spinning process on osx
Daniel Bünzli
daniel.buenzli at erratique.ch
Mon Feb 10 23:12:52 GMT 2014
This thing is driving me crazy. In fact I reached to wrong conclusions about 4.00.1. The problem also exists there. I realized by running some programs for long enough, eventually they'd always exit with bus error 10.
I now have a short repro case that works for both 4.00.1 and 4.01.1 [1]. It exits with bus error 10:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000100c4f3e8
after entering the loop. I checked that a corresponding pure C program has no problem.
I rechecked the bindings of all the functions used until error [2]. Note that just adding something like a printf statement to the loop may make the program work (or at least for a longer time).
I'm at loss.
Daniel
[1]
-----min.ml-------
(*
Minimal OCaml SDL example. This code is in the public domain.
Compile with:
ocamlfind ocamlc -package tsdl -linkpkg -o min.byte min.ml
ocamlfind ocamlopt -package tsdl -linkpkg -o min.native min.ml
*)
open Tsdl
let main () = match Sdl.init Sdl.Init.video with
| `Error -> exit 1
| `Ok () ->
match Sdl.create_window ~w:640 ~h:480 "SDL OpenGL" Sdl.Window.opengl with
| `Error -> exit 1
| `Ok w ->
Printf.printf "Enter%!";
while true do Sdl.gl_swap_window w done;
Sdl.destroy_window w;
Sdl.quit ();
exit 0
let () = main ()
--------------------
[2]
https://hg.libsdl.org/SDL/file/e749005cfd72/include/SDL.h#l129
https://github.com/dbuenzli/tsdl/blob/master/src/tsdl.ml#L187
https://hg.libsdl.org/SDL/file/e749005cfd72/include/SDL_video.h#l408
https://github.com/dbuenzli/tsdl/blob/master/src/tsdl.ml#L1675
https://hg.libsdl.org/SDL/file/e749005cfd72/include/SDL_video.h#l959
https://github.com/dbuenzli/tsdl/blob/master/src/tsdl.ml#L1986
More information about the Ctypes
mailing list