* Re: [Caml-list] Seg fault with -custom and 2049 lets...
2001-04-12 18:31 [Caml-list] Seg fault with -custom and 2049 lets David Fox
@ 2001-04-13 14:01 ` David Fox
2001-04-14 10:40 ` [Caml-list] Just wasted half-an-hour on returned curried functions Mattias Waldau
2001-04-17 15:04 ` [Caml-list] Seg fault with -custom and 2049 lets Xavier Leroy
2 siblings, 0 replies; 5+ messages in thread
From: David Fox @ 2001-04-13 14:01 UTC (permalink / raw)
To: caml-list
By the way, this was on a Pentium 3 machine running Redhat Linux 7.0
and ocaml-3.01.
David Fox <dsfox@COGSCI.ucsd.edu> writes:
> If I create a program with 2049 simple functions:
>
> let f1 () = ()
> let f2 () = ()
> ...
> let f2049 () = ()
>
> (You can build this using yes "" | cat -n | head -2049 |
> sed 's/^[^0-9]*\([0-9]*\)[^0-9]*$/let f\1 () = ()/' > y.ml)
>
> I get a seg fault if I compile it with the -custom flag and use a
> debugging version of malloc:
>
> % ocamlc -custom y.ml -ccopt -lefence
> % ./a.out
>
> Electric Fence 2.2.0 Copyright (C) 1987-1999 Bruce Perens <bruce@perens.com>
> Segmentation fault (core dumped)
> %
>
> or if I link using the debugging library libcamlrund.a:
>
> % ./a.out
> ### O'Caml runtime: debug mode ###
> Initial minor heap size: 128k bytes
> Initial major heap size: 248k bytes
> Initial space overhead: 42%
> Initial max overhead: 1000000%
> Initial heap increment: 248k bytes
> Initial stack limit: 1024k bytes
> file interp.c; line 255 ### Assertion failed: sp >= stack_low
>
> If I use the regular (non-debugging) library I don't get the seg fault
> immediately, but in a real life situation things get ugly pretty
> quickly.
>
> -david
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
>
--
$_='while(read+STDIN,$_,2048){$a=29;$b=73;$c=142;$t=255;@t=map{$_%16or$t^=$c^=(
$m=(11,10,116,100,11,122,20,100)[$_/16%8])&110;$t^=(72,@z=(64,72,$a^=12*($_%16
-2?0:$m&17)),$b^=$_%64?12:0,@z)[$_%8]}(16..271);if((@a=unx"C*",$_)[20]&48){$h
=5;$_=unxb24,join"",@b=map{xB8,unxb8,chr($_^$a[--$h+84])}@ARGV;s/...$/1$&/;$
d=unxV,xb25,$_;$e=256|(ord$b[4])<<9|ord$b[3];$d=$d>>8^($f=$t&($d>>12^$d>>4^
$d^$d/8))<<17,$e=$e>>8^($t&($g=($q=$e>>14&7^$e)^$q*8^$q<<6))<<9,$_=$t[$_]^
(($h>>=8)+=$f+(~$g&$t))for@a[128..$#a]}print+x"C*",@a}';s/x/pack+/g;eval
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Caml-list] Just wasted half-an-hour on returned curried functions
2001-04-12 18:31 [Caml-list] Seg fault with -custom and 2049 lets David Fox
2001-04-13 14:01 ` David Fox
@ 2001-04-14 10:40 ` Mattias Waldau
2001-04-17 15:04 ` [Caml-list] Seg fault with -custom and 2049 lets Xavier Leroy
2 siblings, 0 replies; 5+ messages in thread
From: Mattias Waldau @ 2001-04-14 10:40 UTC (permalink / raw)
To: caml-list
I removed the last int-argument of a function,
but only changed at the calls and in the
body, however not in the arguments, thus I had an unused arg
called ~(idx:int), i.e.
let bar a ~(idx:int) =
{ var = a ; .... }
I created data using this function and these
(now curried) arguments were put into an array, and there is where I
got the type error. It took me 30 minutes to find the true source.
I could have found the error if I would have typed the result of the
above mentioned function either at the return value or in the let,
i.e. writing
let bar a ~(idx:int) :annotated_var =
{ var = a ; .... }
or
let x:annotated_var = ..... in
However, the compiler could have found the error for immediately by
either
1. Told me that ~(idx:int) is an unused argument
2. or, had a special syntax ( for example '=()' ) for curried values, for
example,
and by that immediately complain in the let above.
I know that alternative 2 is an absurd suggestion in the church of FPLs :-)
but I don't like wasting time. Could someone give me some example code
(except lablgtk, which is a nice but very hard to understand program)
where the majority of the returned values are functions.
/mattias
P.s. I don't understand how to get warning using ocamlc, for example in the
below code I both override methods and hide instance variables, but get no
warnings.
let foo () =
let x = 0 in
let x = 1 in
x
let foo () =
let x = 0 in
let x = 1 in
x
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 5+ messages in thread