Proposal: Improved error message of "Error in array index"

Rene de Visser rene_de_visser at hotmail.com
Sun Nov 6 14:35:48 EST 2005


I suggest that the code in GHC.Arr be changed from

error "Error in array index"

to

error "Error in array index" ++ show b ++ show i

so that the bounds and offending index is shown. This is easy to do as the 
information is already available, and would in most cases be of great help 
to the user in guessing which code was causing the error.

Background:

I have some stochastic estimation code which after a few hours running 
produces this error.

I then recompiled with full profiling and did

C:\Haskell\dev>main +RTS -xc
main +RTS -xc

<GHC.Arr.CAF>main: Error in array index

Not very usefull, though I wouldn't have guessed that the code containing 
the error code in GHC.Arr is reduced to a CAF.

Further details:

If I do 1000000 simulations it runs OK.
If I do 10000000 simulations it produces the above error.

There is no case where the array indicies depend on the number of 
simulations (I simply accumulate results).

In my case I can probably figure out where the error occurs, as it must be 
an event with probability between 1e-6 and 1e-7 which In my case gives me a 
clue (I hope I guess correctly).

But in other situations the only chance I guess would be to recompile GHC as 
I suggest above.
Due to the high number of simulations required and the long running time, 
finding the error by bisection would be tedious. Adding debugging code would 
probably increase the run time to days instead of hours.

Rene.




More information about the Glasgow-haskell-users mailing list