Opened 12 months ago

Last modified 12 months ago

#8862 new bug

forkProcess does not play well with heap or time profiling

Reported by: bennofs Owned by: simonmar
Priority: normal Milestone:
Component: Runtime System Version: 7.6.3
Keywords: Cc: simonmar
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:


This is similar to #4512. When doing heap or time profiling, the forked process and the parent process both write to the same .hp or .prof file. I think this also applies to program coverage using hpc (didn't test this).

I was able to reproduce the bug with the attached source code, but some other people were not. Just run space-profiling +RTS -h and try to convert the generated heap profile using hp2ps, I get the following error message:

hp2ps: space-profiling.hp, line 186: integer must follow identifier

I attached the generated hp file.

Attachments (2)

space-profiling.hs (596 bytes) - added by bennofs 12 months ago.
Haskell program demonstrating the bug
space-profiling.hp (11.2 KB) - added by bennofs 12 months ago.
generated heap profile

Download all attachments as: .zip

Change History (5)

Changed 12 months ago by bennofs

Haskell program demonstrating the bug

Changed 12 months ago by bennofs

generated heap profile

comment:1 Changed 12 months ago by bennofs

Side-note: I compiled the program without profiling enabled.

comment:2 Changed 12 months ago by rwbarton

Are you using the threaded runtime?

Maybe it would make sense for the profiling subsystem to use pthread_atfork to ensure that the .hp file is closed in any child processes? (Does that exist on Windows?)

comment:3 Changed 12 months ago by bennofs

I'm not using the threaded runtime. I think this is more difficult than just closing the .hp file. Wouldn't it make sense that the current cost centre stack is discarded in the child process, such that it behaves just like if the IO action passed to forkProcess was main ?

Note: See TracTickets for help on using tickets.