#15608 closed bug (fixed)

Segfault in retainer profiling

Reported by: osa1 Owned by:
Priority: normal Milestone: 8.6.3
Component: Profiling Version: 8.5
Keywords: Cc: maoe
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D5134
Wiki Page:

Description (last modified by osa1)

To reproduce, build ghc using "prof" flavor, then

$ ghc-stage2 --interactive +RTS -hr
GHCi, version 8.7.20180905: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/omer/rcbackup/.ghci
λ:1> sequence_ (replicate 100000000 (return ()))
zsh: segmentation fault (core dumped)  ghc-stage2 --interactive +RTS -hr

If I use debug runtime in stage2 compiler I can't even run the repl:

haskell $ ghc-stage2 --interactive +RTS -hr
rr: Saving execution to trace directory `/home/omer/.local/share/rr/ghc-stage2-13'.
GHCi, version 8.7.20180906: http://www.haskell.org/ghc/  :? for help
zsh: segmentation fault  ghc-stage2 --interactive +RTS -hr

Change History (10)

comment:1 Changed 15 months ago by osa1

Description: modified (diff)

comment:2 Changed 15 months ago by osa1

Differential Rev(s): Phab:D5134

I fixed a few bugs in Phab:D5134. There are still more bugs to fix until this works.

comment:3 Changed 15 months ago by osa1

One of the problems is that because of recursive retainClosure() calls retainer profiler sometimes fills the C stack. I currently see 170000+ stack frames because of this loop:

#174645 retainClosure
    (c0=<optimized out>, cp0=cp0@entry=0x4201ecaa20, r0=r0@entry=0x6810bc0 <CCS_SYSTEM>)
    at rts/RetainerProfile.c:1598

#174646 0x00000000059b48c7 in retain_small_bitmap
    (c_child_r=<optimized out>, c=0x4201ecaa20, bitmap=0, size=<optimized out>, p=0x4201ecaa50)
    at rts/RetainerProfile.c:1140

#174647 retain_PAP_payload
    (n_args=<optimized out>, payload=0x4201ecaa50, fun=<optimized out>, c_child_r=<optimized out>, pap=0x4201ecaa20)
    at rts/RetainerProfile.c:1334

#174648 retainClosure
    (c0=<optimized out>, cp0=cp0@entry=0x4203affe88, r0=r0@entry=0x6810bc0 <CCS_SYSTEM>)
    at rts/RetainerProfile.c:1598

I don't understand how retainer profiler works yet. It has a stack, and a maxStack variable, but I don't understand why we sometimes push work to the stack and sometimes recurse, and maxStack seems to be unused.

Last edited 15 months ago by osa1 (previous) (diff)

comment:4 Changed 15 months ago by bgamari

One of the problems is that because of recursive retainClosure() calls retainer profiler sometimes fills the C stack.

Note that this misfeature of the retainer profiler is being tracked as #14758.

comment:5 Changed 14 months ago by MikolajKonarski

I see that Phab:D5134 is merged, but not to 8.4 branch. Could we milestone this to 8.4.5 once such milestone exists? Ömer says this should be rather safe to merge to 8.4. Thank you!

comment:6 Changed 14 months ago by bgamari

Milestone: 8.6.18.4.5

I am quite doubtful that there will be a 8.4.5 but nevertheless, done.

comment:7 Changed 13 months ago by maoe

Cc: maoe added

comment:8 Changed 13 months ago by osa1

Milestone: 8.4.58.6.3

comment:9 Changed 12 months ago by bgamari

Milestone: 8.6.3

Ticket retargeted after milestone closed

comment:10 Changed 12 months ago by bgamari

Milestone: 8.6.3
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.