Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphics crash under Windows #6

Open
vicuna opened this issue Nov 21, 2016 · 4 comments
Open

Graphics crash under Windows #6

vicuna opened this issue Nov 21, 2016 · 4 comments
Assignees
Labels
mantis Issues imported from Mantis (i.e. old...)

Comments

@vicuna
Copy link

vicuna commented Nov 21, 2016

Original bug ID: 7419
Reporter: Anax
Assigned to: @dra27
Status: assigned (set by @dra27 on 2016-11-22T15:49:09Z)
Resolution: open
Priority: normal
Severity: minor
Platform: Winodws
OS: Windows 10
Version: 4.02.3
Category: platform support (windows, cross-compilation, etc)
Monitored by: @gasche

Bug description

In class, we did some exercices on trees, and in the fil the teacher gave us, there were a function to trace trees (the fact that it is tree is not important).
I don't really know the module graphics.cma, but when I use it to trace a forest here, the forest is tarced, but when I when to close the windows with the space bar (there is the code let _ = read_key() in close_graph() at the end of the function) it crashes I have to launch again ocaml.
I use Windows 10 on my computer, and a friend of mine as the same problem on his Windows. At school, we use ubuntu and it works.

Steps to reproduce

As I don't really know how really works the graphics module, I give you the caml function :

let rec trace_arbre_binaire t (xmin, xmax, ymin, ymax) h =
	match t with
	| Vide -> ()
	| Noeud_Binaire (x, t1, t2) ->
			let dy = (ymax - ymin) / h in
			let xm = (xmin + xmax) / 2 in
			let s = string_of_int x in
			moveto (xm - (10 * String.length s) / 2)  ymax;
			set_color green;
			draw_string s;
			let dx = (xmax - xmin) / 2 in
			set_color yellow;
			if t1 <> Vide then (
				moveto xm (ymax - 5);
				lineto (xmin + dx / 2) (ymax - dy + 15);
			);
			if t2 <> Vide then (
				moveto xm (ymax - 5);
				lineto (xmin + dx / 2 + dx) (ymax - dy + 15);
			);
			trace_arbre_binaire t1 (xmin, xm, ymin, ymax - dy) (h - 1);
			trace_arbre_binaire t2 (xm, xmax, ymin, ymax - dy) (h - 1)

let voir_arbre_binaire t =
	let nx = 800
	and ny = 600 in
	open_graph (" " ^ (string_of_int nx) ^ "x" ^ (string_of_int ny));
	set_color black;
	fill_rect 0 0 nx ny;
	let k = 50 in
	trace_arbre_binaire t (k,nx - k,k,ny - k) (hauteur_arbre_binaire t);
	let _ = read_key() in close_graph();;

where the type 'a arbre is

type 'a arbre_binaire =
|  Vide
|  Noeud_Binaire of 'a * 'a arbre_binaire * 'a arbre_binaire

Additional information

(I'm a French student, so I apologize for my apporxiamtive English)

File attachments

@vicuna
Copy link
Author

vicuna commented Nov 22, 2016

Comment author: @dra27

64-bit OCaml?

I'm fairly sure you hitting a bug fixed in #678 (ocaml/ocaml#678). If you're building OCaml from source, there is a version of this patch back-ported for 4.02.3 at https://github.com/metastack/ocaml-legacy/blob/master/GPR678.patch

@vicuna
Copy link
Author

vicuna commented Nov 22, 2016

Comment author: @dra27

(self-assigned as a reminder to check that 4.04 doesn't exhibit this behaviour - if someone else beats me to it, feel free to close this PR)

@xavierleroy xavierleroy transferred this issue from ocaml/ocaml Mar 16, 2019
@xavierleroy xavierleroy changed the title crash of ocaml when I use Graphics Graphics crash under Windows Mar 16, 2019
@gasche
Copy link
Member

gasche commented Mar 16, 2019

@dra27 if/when you have time, checking that 4.07 doesn't exhibit this behavior would be nice :-)

@ghost
Copy link

ghost commented Mar 18, 2019

Sure. I guess that would be 4.09 though. We are planning to make this library available for OCaml >= 4.09 only.

@dra27 dra27 added the mantis Issues imported from Mantis (i.e. old...) label Dec 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mantis Issues imported from Mantis (i.e. old...)
Projects
None yet
Development

No branches or pull requests

3 participants