eventlog2html icon indicating copy to clipboard operation
eventlog2html copied to clipboard

eventlog2html: Ix{Int}.index: Index (48708) out of range ((0,207))

Open ocharles opened this issue 4 years ago • 11 comments

I periodically seem to get this. Usually re-generating an eventlog fixes it.

ocharles avatar Dec 17 '20 10:12 ocharles

I imagine this is because the eventlog is generated with a newer version of GHC than the ghc-events that eventlog2html can read.

mpickering avatar Dec 17 '20 12:12 mpickering

I don't think so, I have a single nix-shell that I'm using to build my project but also with a pinned version of eventlog2html. As it only happens sometimes I'm wondering if the event log is getting truncated or something. Will try and put some time aside next time it happens to see what's up.

ocharles avatar Dec 17 '20 12:12 ocharles

Could be this GHC issue, which I never got to the bottom of - https://gitlab.haskell.org/ghc/ghc/-/issues/17948

mpickering avatar Dec 18 '20 09:12 mpickering

I just fixed a bug like this I think which was caused by incorrectly calculating the size of an event in GHC. It's quite hard to narrow down though but perhaps I should check all the events to make sure the event is declared to be the correct length.

mpickering avatar Dec 20 '20 22:12 mpickering

@mpickering do you have any news on this? we're hitting this in ~ 50% of the cases. This is especially a problem because we cannot always just rerun the program.

Thanks in advance!

MangoIV avatar Jul 01 '24 11:07 MangoIV

I'm also suspecting that the longer the eventlog gets the higher the probability that this happens, maybe we can make eventlog2html at least recover from these issues?

MangoIV avatar Jul 01 '24 12:07 MangoIV

@MangoIV The issue is related to a corrupted eventlog, either due to a bug in the eventlog writing logic or because the process is terminated when the eventlog is being written.

In any case, I think the fix is to investigate and fix on the GHC side. I don't think I have ever been able to reproduce this problem consistently enough to investigate.

mpickering avatar Jul 01 '24 12:07 mpickering

All the decoding of the eventlog is done by the ghc-events library. The ghc-events library also has an executable with a ghc-events show command. If we have a corrupted eventlog it might be a good idea to test it with ghc-events show to see if we can also trigger the bug in that way.

BinderDavid avatar Jul 01 '24 12:07 BinderDavid

good idea @BinderDavid , thank you

MangoIV avatar Jul 01 '24 12:07 MangoIV

after seeing both hs-speedscope and eventlog2html fail, I was suspecting, that ghc-events show would fail as well, and indeed, it fails with the same index error as the two.

This is a small program that (more or less, sometimes it doesn't happen) reliably makes me hit this:

module Main where

import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import Data.Foldable (for_)
import Data.Monoid (Endo (..))

largeEndo :: Endo ByteString
largeEndo = Endo \x -> BS.replicate 100 97 <> x

manyEndos :: Endo ByteString -> Endo ByteString
manyEndos = mconcat . replicate 10_000

main :: IO ()
main = for_ [1 .. 30] \_ ->
  BS.putStr $ appEndo (manyEndos largeEndo) mempty

compile with ghc -rtsopts -prof -fprof-late -O0 ./bla.hs run with ./bla +RTS -hc -p -l-au

MangoIV avatar Aug 13 '24 13:08 MangoIV

I can reproduce this (GHC-9.10, ghc-events-HEAD). Perhaps you could open an issue on the ghc-events tracker @MangoIV: https://github.com/haskell/ghc-events/issues?

TeofilC avatar Aug 13 '24 13:08 TeofilC