48

In the exception stack for runtime crashes, Swift often says arguments are Dead or Exploded. What does it mean, and does it matter for debugging purposes?

For example:

-> 0x100209cf0 <function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> ()+44>: brk    #0x1

Thanks.

DenverCoder9
  • 3,635
  • 3
  • 31
  • 57
  • Similar question: http://stackoverflow.com/questions/31397116/what-does-arg-exploded-mean-in-swift-crash-log – JAL Jul 29 '15 at 02:47

3 Answers3

83

What does it mean?

The Swift compiler marks function arguments for a number of reasons, mostly related to internal optimizations. For your question, we'll focus on the mangler, as that's what's contributing to your pretty stack trace, and the Node Printer. As of the time of this post, the function specialization mangler has 6 marks it can apply to an argument:

  • Dead

    The argument is unused in the function body and can be removed in a dead argument elimination pass.

  • Closure

    The argument is a closure and may require further mangling/demangling.

  • Constant

    The argument is a constant.

  • Owned to Guaranteed

    A caller-owned argument transfers ownership to the callee. The argument thus has a strong reference associated with it [the caller] and is guaranteed to live through the call, so the compiler allows the caller to elide the transfer and instead aggregate retains itself.

  • SROA

    A Scalar Replacement of Aggregates pass should optimize this argument.

  • In Out To Value

    The parameter was marked inout but the callee doesn't actually mutate it.

The AST Node Printer adds one more mark

  • Exploded

    The value comes with an explosion schema that has been realized when the call was made.

For all intents and purposes we only care about Dead, Owned to Guaranteed, and Exploded.

The only one that may still seem mystifying is Exploded. An Explosion is an optimization construct the Swift compiler uses to determine a strategy to unpack values from small structs and enums into registers. Thus, when the Node Printer says a value is Exploded, what it means it has already unpacked the value into registers before the call.

does it matter for debugging purposes?

Nope.

Community
  • 1
  • 1
CodaFi
  • 43,043
  • 8
  • 107
  • 153
  • 2
    Great info. Where did you find out about all this? – jtbandes Jul 31 '15 at 02:13
  • 5
    Hopper, Joe Groff, Intuition. – CodaFi Jul 31 '15 at 02:14
  • Thank you for your detailed answer! It's also worth noting that `function signature specialization` means that there was an issue with the Swift APIs where Objective-C needed to pass a nil parameter value to Swift, but the Swift version of this parameter was not typed as an Optional (http://stackoverflow.com/a/31141957/2415822). – JAL Aug 01 '15 at 05:32
  • @JAL I don't buy that as a proper explanation. There may be some correlation between the case he describes and the error messages that can be produced, but AFAIK these messages are generated at compile time solely for tracking optimizations with stack traces. – CodaFi Aug 01 '15 at 05:35
  • @CodaFi so they mean nothing to the common user then? – JAL Aug 01 '15 at 05:36
  • 4
    @JAL Absolutely nothing, unless the common user happens to be a compiler engineer ;) – CodaFi Aug 01 '15 at 05:37
  • how to fix the dead arg[0]? pass a weak object? – justicepenny Aug 17 '18 at 11:43
1

Dead usually means that the value is no longer in memory

Not sure how this is going to help you unless you are really going to dive into Assembly debugging.

You might want to check out some online resources, i.e., how to use the debugger in Xcode to troubleshoot issues with your code.

Race B
  • 1,193
  • 1
  • 8
  • 7
0

Based on what I was able to find on Apple's developer library, I believe that when Swift says the argument is exploded, it has been expanded to show the bug until it shows all layers and parts of the argument. Swift does this to make it easier to find bugs that are nested between layers of an argument. I am not sure what dead means. This may be completely off base, but I figure that since you haven't gotten an answer in 6 days, I might as well try and clarify you're problem.

jbcd13
  • 145
  • 8