Version française
Home     About     Download     Resources     Contact us    
Browse thread
Crash reading a file
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Adam Chlipala <achlipala@j...>
Subject: Re: [Caml-list] Crash reading a file
Your function isn't tail recursive, so it uses stack space proportional 
to the number of lines in the file.  "Segmentation fault" may be your 
architecture's "stack overflow" error.

tmp123 wrote:
> The following program (foo.ml):
>
> value rec read_stdin () =
>  try
>    [ (input_line Pervasives.stdin) :: (read_stdin ()) ]
>  with [ End_of_file -> [] ];
>
> value main () =
>  read_stdin();
>
> main();
>
>
> when compiled with "ocamlopt -pp camlp4r foo.ml" and executed 
> "./a.out", produces a segmentation fault, but I'm not able to find why.
>
> Please, has someone any sugestion?