seg fault with List.tabulate in 3.9.1

Niels Hallenberg nh@it-c.dk
09 Jul 2001 09:50:05 +0200


Hi Stephen,

> The following program seg faults when compiled with version 3.9.1.
> 
> val _ = List.tabulate (1000000, fn i => i)

The ML Kit stores finite regions on the stack, and therefore uses more
stack space than one would normally assume. Your program above uses
more than the (on my Linux) default 8 Kb.

The cure is to increase the stacksize with the limit and unlimit
command:

[9:45-test_dev]# cat stephen_weeks2.sml
val _ = List.tabulate (1000000, fn i => i)
[9:45-test_dev]# limit
cputime 	unlimited
filesize 	unlimited
datasize 	unlimited
stacksize 	8192 kbytes
coredumpsize 	0 kbytes
memoryuse 	unlimited
descriptors 	1024 
memorylocked 	unlimited
maxproc 	12286 
openfiles 	1024 
[9:45-test_dev]# mlkit stephen_weeks2.sml
ML Kit version 3.9.1, Jul 06, 2001 [X86 Backend]
[reading source file:	stephen_weeks2.sml]
[wrote X86 code file:	/home/nh/ITU/MLKit/mlkit/kit/test_dev/PM/NoProf/stephen_weeks2.sml-stephen_weeks2.sml.s]
[wrote X86 code file:	/home/nh/ITU/MLKit/mlkit/kit/test_dev/PM/NoProf/link_objects.s]
[wrote executable file:	run]
[9:46-test_dev]# run
Segmentation fault

We get a segmentation fault because the stacksize is only 8 Kb.

[9:46-test_dev]# unlimit stacksize
[9:46-test_dev]# limit
cputime 	unlimited
filesize 	unlimited
datasize 	unlimited
stacksize 	unlimited
coredumpsize 	0 kbytes
memoryuse 	unlimited
descriptors 	1024 
memorylocked 	unlimited
maxproc 	12286 
openfiles 	1024 
[9:46-test_dev]# run
[9:46-test_dev]# 

Now it works.

Happy Hacking

-- Niels
-------------------------------------------------------
Niels Hallenberg                 Email: nh@it.edu
The IT University of Copenhagen  Tel.:  +45-38 16 88 24
Glentevej 67                     Fax:   +45-38 16 88 99
DK-2400 Copenhagen NV            WWW:   www.it.edu
-------------------------------------------------------