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

Segmentation Fault on Fairly trivial program #3198

Closed
vicuna opened this issue Oct 6, 2004 · 3 comments
Closed

Segmentation Fault on Fairly trivial program #3198

vicuna opened this issue Oct 6, 2004 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Oct 6, 2004

Original bug ID: 3198
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Joseph E. Gonzalez
Version: 3.08.1
OS: Linux 2.6.8-1.521smp x86_64
Submission from: fleming-55.caltech.edu (131.215.87.55)

I wrote a simple program to test performance (the following one):

let rec random_list x list = match x with
| 0 -> list
| _ -> random_list (x - 1) ((Random.int 999999999)::list);;

let l = (random_list 999999 []);;

let y = (List.map (function x -> x) l);;

and compiled it using the command:
ocamlopt prof.ml -o prof

when I run it I get a segmentation fault. This does not happen on my other
systems. When I used gdb the fault is said to be in
camlList__map_86 ()

Thanks
-Joey

@vicuna
Copy link
Author

vicuna commented Oct 7, 2004

Comment author: administrator

Full_Name: Joseph E. Gonzalez
Version: 3.08.1
OS: Linux 2.6.8-1.521smp x86_64
Submission from: fleming-55.caltech.edu (131.215.87.55)

I wrote a simple program to test performance (the following one):

let rec random_list x list = match x with
| 0 -> list
| _ -> random_list (x - 1) ((Random.int 999999999)::list);;

let l = (random_list 999999 []);;

let y = (List.map (function x -> x) l);;

and compiled it using the command:
ocamlopt prof.ml -o prof

when I run it I get a segmentation fault.

This looks like you've hit a limit that your shell has on stack size. Could you
please make sure you have no limit on stack or memory size (ulimit -a, with
bash), and re-run your `prof' executable?

-- Michel Mauny

@vicuna
Copy link
Author

vicuna commented Oct 9, 2004

Comment author: administrator

I wrote a simple program to test performance (the following one):

let rec random_list x list = match x with
| 0 -> list
| _ -> random_list (x - 1) ((Random.int 999999999)::list);;

let l = (random_list 999999 []);;

let y = (List.map (function x -> x) l);;

and compiled it using the command:
ocamlopt prof.ml -o prof

when I run it I get a segmentation fault. This does not happen on my other
systems. When I used gdb the fault is said to be in
camlList__map_86 ()

This looks like a stack overflow (List.map is not tail-recursive).
On Intel x86, stack overflow (reported by the Unix kernel as a
segmentation fault) is caught and mapped to a Caml exception, but this
is not (yet) the case on x86_64.

You might be able to get your code to run by raising the Unix stack
size limit (command "ulimit"). Also, consider List.rev_map
(tail-recursive) instead of List.map.

Hope this helps,

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Jul 31, 2005

Comment author: administrator

Just a stack overflow. Feature wish: Stack_overflow exception on AMD64/Linux.
Implemented in 3.09.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant