Fixed in 10.1.0.
Consider the following function, which generates uniformly random points on the surface of the 2-sphere:
randSphere[] := Block[{z = RandomReal[{-1, 1}, 3]},
If[Total[z^2] > 1, randSphere[], Normalize[z]]]
I can use this function to generate a Table of 249 points:
Table[randSphere[], {249}] (* works fine *)
but mysteriously, changing 249 to 250 consistently crashes the kernel. I am running Mathematica 10.0.2 on Windows. What's going on here? It's worth noting that I can also generate 249 pairs of points with no problems:
Table[{randSphere[], randSphere[]}, {249}] (* also works fine *)
and I can even generate 249 Tables of 249 points:
Table[Table[randSphere[], {249}], {249}] (* still fine *)
but changing any instance of 249 to 250 in each of the above examples crashes the kernel again.


Tablewill attempt to auto-compile its first argument starting at 250, which is certainly related to the crash. TheCompileOptionssetting fromSystemOptionscontrols this. – Szabolcs Dec 30 '14 at 18:13randSphere. The workaround is to get rid of that (use aWhile[... > 1, (* recompute *)]sort of thing).Compiledoesn't support recursive calls. I'm tagging this as a bug, please report it tosupportatwolfram.com. – Szabolcs Dec 30 '14 at 18:15Tabledon't mention anything special about250. – David Zhang Dec 30 '14 at 18:16SetSystemOptions["CompileOptions" -> "TableCompileLength" -> 300]to set it to 300. I don't mean this as a workaround though. – Szabolcs Dec 30 '14 at 18:21SystemOptions["CompileOptions"]. – Karsten7 Dec 30 '14 at 18:25Compile[{}, randSphere[]]itself crashes my kernel (V10.0.1 Mac OSX 10.9.5). I'm not sure of the relation to the OP's problem, since autocompile might do a different command. – Michael E2 Dec 30 '14 at 19:09Compilewill not know what is getting returned. The variant below makes this explicit, and has the pleasant side effect of circumventing the crash.ff = Compile[{}, randSphere[], {{_randSphere,_Real,1}}]; Table[ff[],{250}]I do not understand how this manages to evade the crash. Which is weird, since I now know what causes said crash. One of those mysteries. – Daniel Lichtblau Dec 30 '14 at 20:57