Upgrade to Pro — share decks privately, control downloads, hide ads and more …

App Extension のスタックトレース情報からクラッシュを解析/集計する / Analyzing app extension's stack trace

naru-jpn
September 18, 2021

App Extension のスタックトレース情報からクラッシュを解析/集計する / Analyzing app extension's stack trace

配信アプリで使用している Broadcast Extension 上で発生したクラッシュの詳細について、クラッシュ発生時のスタックトレースを取得して解析し、複数のクラッシュの修正に繋げた話。

naru-jpn

September 18, 2021
Tweet

More Decks by naru-jpn

Other Decks in Technology

Transcript

  1. Ϋϥογϡݕ஌ͱϋϯυϦϯά class func setup() { // ྫ֎ͷݕ஌ͱ࣮ߦ͢Δؔ਺ͷࢦఆ NSSetUncaughtExceptionHandler(exceptionHandler) // γάφϧͷݕ஌ͱ࣮ߦ͢Δؔ਺ͷࢦఆ

    for sigcontext in [SIGABRT, SIGILL, SIGSEGV, SIGFPE, SIGBUS, SIGPIPE, SIGTRAP] { signal(sigcontext, signalHandler) } } private static let exceptionHandler: @convention(c) (NSException) -> () = { exeption in handleSignalException(exeption: exeption) } private static let signalHandler: @convention(c) (Int32) -> () = { signal in handleSignalException() } https://stackover fl ow.com/questions/36325140/how-to-catch-a-swift-crash-and-do-some-logging
  2. ίʔϧελοΫͷऔಘ let callstack = exception.callStackSymbols.joined(separator: “\n”) // ΋͘͠͸ let callstack

    = Thread.callStackSymbols.joined(separator: “\n”) 0 broadcast-upload 0x000000010502eaf8 broadcast-upload + 223992 1 libsystem_platform.dylib 0x00000001e3b9c29c 987D48D5-3CAA-34D7-9141-C0BD6E2351E8 + 21148 2 broadcast-upload 0x0000000105106224 broadcast-upload + 1106468 3 broadcast-upload 0x0000000105103604 broadcast-upload + 1095172 4 Foundation 0x00000001991eb438 __NSFireTimer + 104 5 CoreFoundation 0x0000000197d911d4 338F58B1-9B75-38A0-B908-E2574AB1D39A + 672212 6 CoreFoundation 0x0000000197d90dd0 338F58B1-9B75-38A0-B908-E2574AB1D39A + 671184 7 CoreFoundation 0x0000000197d90220 338F58B1-9B75-38A0-B908-E2574AB1D39A + 668192 8 CoreFoundation 0x0000000197d89f8c 338F58B1-9B75-38A0-B908-E2574AB1D39A + 642956 … ͜ͷίʔϧελοΫͷ৘ใΛղੳͯ͠ɺϓϩάϥϜͷ࣮ߦߦ਺ͳͲΛಛఆ͍ͨ͠
  3. E4:.ϑΝΠϧ͕ͲͷλʔήοτϥΠϒϥϦʹରԠ͍ͯ͠Δ͔ௐ΂Δ Mirrativ tech blog - ʲiOSʳUnity Framework ͱΫϥογϡղੳͷऔΓ૊Έ files=`ls "$1"`

    for uuid in ${files[@]}; do module=`ls "$1/${uuid}/Contents/Resources/DWARF/"` echo "${uuid:0:8}: ${module}" done fi OE@ETZNTI
  4. Mirrativ tech blog - ʲiOSʳUnity Framework ͱΫϥογϡղੳͷऔΓ૊Έ $ ./find_dsym.sh /Users/naruki.chigira/Desktop/appDsyms

    2d4dd1c9: widget 310ef0bf: broadcast-upload 6d82e920: WebRTC 7cc5d65f: UnityFramework b11f4f4f: Shared de357eed: mirrativ … ֤λʔήοτϥΠϒϥϦʹରԠ͢ΔE4:.͕؆୯ʹ୳ͤΔΑ͏ʹͳͬͨ E4:.ϑΝΠϧ͕ͲͷλʔήοτϥΠϒϥϦʹରԠ͍ͯ͠Δ͔ௐ΂Δ
  5. BUPTͷجຊతͳ࢖͍ํΛ஌Δ $ man atos atos(1) BSD General Commands Manual atos(1)

    NAME atos -- convert numeric addresses to symbols of binary images or processes SYNOPSIS atos [-o <binary-image-file>] [-p <pid> | <partial-executable-name>] [-arch architecture] [-l <load-address>] [-s <slide>] [-printHeader] [-fullPath] [-f <address- input-file>] [<address> …] … NBOίϚϯυͰ֬ೝͯ͠ΈΔ atos [-o <binary-image-file>] [-arch architecture] [-l <load-address>] [<address> …] ࠓճͷΫϥογϡղੳͷࡍʹඞཁͳύϥϝʔλ
  6. BUPTʹ౉͢ύϥϝʔλE4:.ϑΝΠϧ atos [-o <binary-image-file>] [-arch architecture] [-l <load-address>] [<address> …]

    Ϋϥογϡղੳͷࡍʹඞཁͳύϥϝʔλ E4:.ϑΝΠϧͷύε த਎ 0 broadcast-upload 0x000000010502eaf8 broadcast-upload + 223992 ./appDsyms/310ef0bf-51fa-3535-8078-3fa06c470774.dSYM/Contents/Resources/DWARF/broadcast-upload
  7. BUPTʹ౉͢ύϥϝʔλΞʔΩςΫνϟ atos [-o <binary-image-file>] [-arch architecture] [-l <load-address>] [<address> …]

    Ϋϥογϡղੳͷࡍʹඞཁͳύϥϝʔλ Ϋϥογϡ͕ൃੜͨ͠୺຤ͷ$16ΞʔΩςΫνϟ BSN BSNF
  8. atos [-o <binary-image-file>] [-arch architecture] [-l <load-address>] [<address> …] Ϋϥογϡղੳͷࡍʹඞཁͳύϥϝʔλ

    -l 0x104ff8000 0x10502eaf8 0 broadcast-upload 0x000000010502eaf8 broadcast-upload + 223992 " # https://stackover fl ow.com/questions/11747802/symbolicating-stack-trace-without-crash " "# BUPTʹ౉͢ύϥϝʔλελοΫτϨʔεͷΞυϨε
  9. atos [-o <binary-image-file>] [-arch architecture] [-l <load-address>] [<address> …] Ϋϥογϡղੳͷࡍʹඞཁͳύϥϝʔλ

    -l 0x104ff8000 0x10502eaf8 0 broadcast-upload 0x000000010502eaf8 broadcast-upload + 223992 " # https://stackover fl ow.com/questions/11747802/symbolicating-stack-trace-without-crash "# BUPTʹ౉͢ύϥϝʔλελοΫτϨʔεͷΞυϨε "0x" + String(UInt64("10502eaf8", radix: 16)! - UInt64("223992", radix: 10)!, radix: 16)
  10. $ atos -o {path_to_dsym} -arch arm64e -l 0x104ff8000 0x10502eaf8 0

    broadcast-upload 0x000000010502eaf8 broadcast-upload + 223992 https://stackover fl ow.com/questions/11747802/symbolicating-stack-trace-without-crash ελοΫτϨʔεΛղੳ͢Δ closure #1 in variable initialization expression of static AnalyticsManager.recieveSignal (in broadcast-upload) (AnalyticsManager+Extension.swift:22) 🎉
  11. $ atos -o {path_to_dsym} -arch arm64e -l 0x104ff8000 0x105106224 0x105103604

    2 broadcast-upload 0x0000000105106224 broadcast-upload + 1106468 3 broadcast-upload 0x0000000105103604 broadcast-upload + 1095172 https://stackover fl ow.com/questions/11747802/symbolicating-stack-trace-without-crash ελοΫτϨʔεΛղੳ͢Δ specialized Stream.on(timer:) (in broadcast-upload) (Stream.swift:164) @objc Stream.on(timer:) (in broadcast-upload) (<compiler-generated>:0) 🎉
  12. $ atos -o {path_to_dsym} -arch arm64e -l 0x104ff8000 0x10502eaf8 ࣮༻্ͷ՝୊

    ɾE4:.ϑΝΠϧͷࢦఆ΍ΞυϨεͷܭࢉ͕खؒ ɾ࣮ߦʹ͕͔͔࣌ؒΔ ɹɾUJNFίϚϯυͰܭଌ͢Δͱ()[.BD#PPL1SPͰ<T> ˠख࡞ۀͰ͸ղੳͰ͖ͳ͍͠ɺେྔͷϩάΛղੳ͢Δʹ͸Ωϟογϡ తͳ࢓૊Έ͕ඞཁ