#14970 closed bug (fixed)

GHC.Err.errorWithoutStackTrace produces stack trace when profiling enabled

Reported by: rotaerk Owned by: simonmar
Priority: normal Milestone: 8.6.1
Component: libraries/base Version: 8.2.2
Keywords: Cc: simonmar, dfeuer
Operating System: Linux Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D4648
Wiki Page:

Description

When you run 'error', it shows the usual stack trace. When you enable profiling with the -prof flag to ghc, and you run 'error', it shows the usual stack trace plus an additional prof-specific stack trace.

When you run 'errorWithoutStackTrace' with profiling enabled, it strips the usual stack trace of 'error', but still displays the prof-specific stack trace.

Change History (9)

comment:1 Changed 21 months ago by osa1

Cc: simonmar added

Why do you think this is a bug? We're talking about two kinds of stacks here

  1. Stack trace constructed by user-provided HasCallStack constraints
  1. Stack trace constructed by the RTS and generated code via (sometimes auto-generated) SCC annotations (aka. "cost-centre stack")

and it's quite possible that these two stack traces show different things, they have different purposes. errorWithoutStackTrace overrides (1) but it can't override (2), (2) is a lower-level thing.

Paging simonmar as he made error include the CCS stack in profiling mode in Phab:D1426.

comment:2 Changed 21 months ago by rotaerk

I don't know for sure that it's a bug. The apparent intent of errorWithoutStackTrace was not being followed, so I wanted to draw attention to it. Someone might call this with the expectation that they get only the error message, and then suddenly the behavior changes when they turn on profiling. If someone with familiarity with the decisions behind the implementation declares this to be intended behavior, the ticket can be closed.

Last edited 21 months ago by rotaerk (previous) (diff)

comment:3 Changed 21 months ago by bgamari

Indeed I think this is expected. The point (as I understand it) of errorWithoutStackTrace is to avoid the (potential) runtime cost of HasCallStack. In the case of the CCS stack there is no additional cost to providing the stack-trace.

We probably ought to document this, however.

comment:4 Changed 21 months ago by simonmar

Milestone: 8.4.2
Owner: set to simonmar

comment:5 Changed 20 months ago by bgamari

Milestone: 8.4.28.6.1

comment:6 Changed 20 months ago by simonmar

Differential Rev(s): Phab:D4648

comment:7 Changed 20 months ago by dfeuer

Cc: dfeuer added

bgamari, that's a bit tricky. It's only possible to avoid building the call stack if the demand analyzer can see that it won't be used. I think the only reliable way to avoid building one is to be careful with your constraints.

comment:8 Changed 20 months ago by Simon Marlow <marlowsd@…>

In dc655bf0/ghc:

errorWithoutStackTrace: omit profiling stack trace (#14970)

Test Plan: validate

Reviewers: hvr, bgamari, erikd

Subscribers: thomie, carter

Differential Revision: https://phabricator.haskell.org/D4648

comment:9 Changed 20 months ago by simonmar

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