You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 1955 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Samuel Colin
Version: 3.07+2
OS: Linux
Submission from: alille-209-1-12-176.w81-249.abo.wanadoo.fr (81.249.41.176)
While mixing graphical and threaded programming, I happened to find some strange
bugs. First, here is a piece of code for you to test:
(**************)
open Graphics
let inputThread ()=
let gotEvent=Graphics.wait_next_event [Graphics.Button_down] in
print_endline ("mouse:" ^ (string_of_int gotEvent.mouse_x)
^ "," ^ (string_of_int gotEvent.mouse_y));
flush stdout
let _=
Graphics.open_graph "";
let t=Thread.create inputThread () in
let tid=Thread.id t in
Thread.join t;
Graphics.close_graph ()
(***************)
Compilations are made with:
ocamlc -o test -thread unix.cma threads.cma graphics.cma test.ml
and
ocamlopt -o test -thread unix.cmxa threads.cmxa graphics.cmxa test.ml
The second execution makes a segmentation fault (maybe does it come from the OS,
but I'm not sure).
And replacing "Thread.join t" with "ignore (Thread.wait_pid tid)" yields:
scolin@hebus:~/tmp/test$ ./test
Fatal error: exception Unix.Unix_error(5, "waitpid", "")
Given the documentation of the thread library, maybe the Graphics library should
be compiled with the "-thread" option?
The second bug comes from the Graphics library used in conjunction with the
Thread library (doesn't happen if the code of the inputThread function is put
directly in the "main" function):
-Bytecode : the event is detected, the mouse position is returned as expected
-Native code : the event is not detected, so the program doesn't end.
Adding Graphics.Poll in the list of events solves the problem, but maybe one
doesn't want to wait for the Poll event...
So, maybe all these bugs simply come from the fact that the Graphics library
isn't thread-safe.
Hope this helps...
The text was updated successfully, but these errors were encountered:
Original bug ID: 1955
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Samuel Colin
Version: 3.07+2
OS: Linux
Submission from: alille-209-1-12-176.w81-249.abo.wanadoo.fr (81.249.41.176)
While mixing graphical and threaded programming, I happened to find some strange
bugs. First, here is a piece of code for you to test:
(**************)
open Graphics
let inputThread ()=
let gotEvent=Graphics.wait_next_event [Graphics.Button_down] in
print_endline ("mouse:" ^ (string_of_int gotEvent.mouse_x)
^ "," ^ (string_of_int gotEvent.mouse_y));
flush stdout
let _=
Graphics.open_graph "";
let t=Thread.create inputThread () in
let tid=Thread.id t in
Thread.join t;
Graphics.close_graph ()
(***************)
Compilations are made with:
ocamlc -o test -thread unix.cma threads.cma graphics.cma test.ml
and
ocamlopt -o test -thread unix.cmxa threads.cmxa graphics.cmxa test.ml
Bugs found:
-Bytecode :
scolin@hebus:
/tmp/test$ ./test/tmp/test$ ./testmouse:31,269
scolin@hebus:
mouse:280,222
Erreur de segmentation
The second execution makes a segmentation fault (maybe does it come from the OS,
but I'm not sure).
And replacing "Thread.join t" with "ignore (Thread.wait_pid tid)" yields:
scolin@hebus:~/tmp/test$ ./test
Fatal error: exception Unix.Unix_error(5, "waitpid", "")
Given the documentation of the thread library, maybe the Graphics library should
be compiled with the "-thread" option?
The second bug comes from the Graphics library used in conjunction with the
Thread library (doesn't happen if the code of the inputThread function is put
directly in the "main" function):
-Bytecode : the event is detected, the mouse position is returned as expected
-Native code : the event is not detected, so the program doesn't end.
Adding Graphics.Poll in the list of events solves the problem, but maybe one
doesn't want to wait for the Poll event...
So, maybe all these bugs simply come from the fact that the Graphics library
isn't thread-safe.
Hope this helps...
The text was updated successfully, but these errors were encountered: