Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash at macOS Runtime, possible recursive error? #34

Closed
tikimcfee opened this issue Jun 15, 2021 · 10 comments
Closed

Crash at macOS Runtime, possible recursive error? #34

tikimcfee opened this issue Jun 15, 2021 · 10 comments

Comments

@tikimcfee
Copy link
Contributor

tikimcfee commented Jun 15, 2021

Hey there - awesome library, looking forward to integrating this and giving it a try in my applications!

On first run, I'm getting a long what seems to be recursive stack trace when attempting to track instances of a single class (I'm not using the bundle methods right now). I'm linking a .gist with the full trace, it's rather long, but the info is below.

Trace Gist:
https://gist.github.com/tikimcfee/8cdfaefd84e62bc61c69d1c1ed99ee53

/*
Error line:
       let threadLocal = ThreadLocal.current() // (!) Thread 1: EXC_BAD_ACCESS (code=2, address=0x16d097fd0)
*/

static var onEntry: @convention(c) (_ swizzle: Swizzle, _ returnAddress: UnsafeRawPointer,
   _ stackPointer: UnsafeMutablePointer<UInt64>) -> IMP? = {
       (swizzle, returnAddress, stackPointer) -> IMP? in
       let threadLocal = ThreadLocal.current() // (!) Thread 1: EXC_BAD_ACCESS (code=2, address=0x16d097fd0)
       let invocation = swizzle.invocationFactory
           .init(stackDepth: threadLocal.invocationStack.count, swizzle: swizzle,
                 returnAddress: returnAddress, stackPointer: stackPointer)
       invocation.saveLevelsTracing = threadLocal.levelsTracing
       threadLocal.invocationStack.append(invocation)
       swizzle.onEntry(stack: &invocation.entryStack.pointee)
       if invocation.shouldDecorate {
            threadLocal.levelsTracing -= 1
       }
       return swizzle.nullImplmentation != nil ?
           autoBitCast(swizzle.nullImplmentation) : swizzle.implementation
}

I'm running this:

XCode Version 12.5 (12E262)`
MacBook Air (M1, 2020)

https://github.com/johnno1962/SwiftTrace/  @ 7.4.2

Much appreciate your time and help, and again, thanks for the great tool!

EDIT: Version is 7.4.2, not 0.7.4

@johnno1962
Copy link
Owner

Hi, first thing to check is that you're using the right version. It says https://github.com/johnno1962/SwiftTrace/ @ 0.7.4 at the end but the current tag is 7.4.2, how are you adding it to your project? The best way is as a Swift Package.

@tikimcfee
Copy link
Contributor Author

Whoops, sorry for that - typo or something. The version I'm using is indeed 7.4.2. Just double checked and reran to confirm.

@johnno1962
Copy link
Owner

johnno1962 commented Jun 15, 2021

When it does this sort of recursion it's usually because something has been swizzled that SwiftTrace itself uses. When you look at the stack trace can you see the method "signature" in the "swizzle" instance which looks after the forwarding?

@tikimcfee
Copy link
Contributor Author

Took that advice and moved the trace call even higher in the app, to didFinishLaunching. Unfortunately, same problem. Here's a block that highlights the startup flow:

#52218	0x0000000106f8bf44 in closure #1 in variable initialization expression of static SwiftTrace.Swizzle.onEntry at /Users/lugos/Library/Developer/Xcode/DerivedData/LookAtThat_AppKit-cknqatlzjmsdpwghvnspbgummawg/SourcePackages/checkouts/SwiftTrace/SwiftTrace/SwiftSwizzle.swift:159
#52219	0x0000000106f8c8b0 in @objc closure #1 in variable initialization expression of static SwiftTrace.Swizzle.onEntry ()
#52220	0x00000001225d4050 in 0x1225d4050 ()
#52221	0x0000000181c3bf7c in CALLING_SOME_+initialize_METHOD ()
#52222	0x0000000181c3ca88 in initializeNonMetaClass ()
#52223	0x0000000181c3df98 in initializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt<false>&, bool) ()
#52224	0x0000000181c2bc44 in lookUpImpOrForward ()
#52225	0x0000000181c2b544 in _objc_msgSend_uncached ()
#52226	0x0000000106f8b774 in type metadata accessor for SwiftTrace.Swizzle.ThreadLocal ()
#52227	0x0000000106f8bf44 in closure #1 in variable initialization expression of static SwiftTrace.Swizzle.onEntry at /Users/lugos/Library/Developer/Xcode/DerivedData/LookAtThat_AppKit-cknqatlzjmsdpwghvnspbgummawg/SourcePackages/checkouts/SwiftTrace/SwiftTrace/SwiftSwizzle.swift:159
#52228	0x0000000106f8c8b0 in @objc closure #1 in variable initialization expression of static SwiftTrace.Swizzle.onEntry ()
#52229	0x00000001225d4050 in 0x1225d4050 ()
#52230	0x0000000181c3bf7c in CALLING_SOME_+initialize_METHOD ()
#52231	0x0000000181c3ca88 in initializeNonMetaClass ()
#52232	0x0000000181c3df98 in initializeAndMaybeRelock(objc_class*, objc_object*, mutex_tt<false>&, bool) ()
#52233	0x0000000181c2bc44 in lookUpImpOrForward ()
#52234	0x0000000181c2b544 in _objc_msgSend_uncached ()
#52235	0x0000000104b7236c in type metadata accessor for WordNodeBuilder ()
#52236	0x0000000104b8e20c in SceneLibrary.().init() at /Users/lugos/udev/manicmind/LookAtThat/Interop/SharedSceneKit/SceneLibrary.swift:13
#52237	0x0000000104b8c4e4 in SceneLibrary.__allocating_init() ()
#52238	0x0000000104b8c4a0 in one-time initialization function for global at /Users/lugos/udev/manicmind/LookAtThat/Interop/SharedSceneKit/SceneLibrary.swift:11
#52239	0x0000000107191dcc in _dispatch_client_callout ()
#52240	0x0000000107193d34 in _dispatch_once_callout ()
#52241	0x000000018ddd6b40 in swift_once ()
#52242	0x0000000104b8c530 in SceneLibrary.global.unsafeMutableAddressor at /Users/lugos/udev/manicmind/LookAtThat/Interop/SharedSceneKit/SceneLibrary.swift:11
#52243	0x0000000104b381cc in MacAppRootView.init() at /Users/lugos/udev/manicmind/LookAtThat/LookAtThat_AppKit/SwiftUIViews/MacAppRootView.swift:5
#52244	0x0000000104b62e54 in AppDelegate.applicationDidFinishLaunching(_:) at /Users/lugos/udev/manicmind/LookAtThat/LookAtThat_AppKit/AppDelegate.swift:22
#52245	0x0000000104b63820 in @objc AppDelegate.applicationDidFinishLaunching(_:) ()
#52246	0x0000000181e87348 in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#52247	0x0000000181f2928c in ___CFXRegistrationPost_block_invoke ()
#52248	0x0000000181f291f8 in _CFXRegistrationPost ()
#52249	0x0000000181e55e10 in _CFXNotificationPost ()
#52250	0x0000000182bdf620 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#52251	0x0000000184688b84 in -[NSApplication _postDidFinishNotification] ()
#52252	0x000000018468889c in -[NSApplication _sendFinishLaunchingNotification] ()
#52253	0x0000000184685988 in -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] ()
#52254	0x0000000184685570 in -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] ()
#52255	0x0000000182c0c464 in -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()
#52256	0x0000000182c0c29c in _NSAppleEventManagerGenericHandler ()
#52257	0x0000000187b2385c in ___lldb_unnamed_symbol70$$AE ()
#52258	0x0000000187b230d8 in ___lldb_unnamed_symbol69$$AE ()
#52259	0x0000000187b1bb8c in aeProcessAppleEvent ()
#52260	0x0000000189dbcd8c in AEProcessAppleEvent ()
#52261	0x000000018467f868 in _DPSNextEvent ()
#52262	0x000000018467de20 in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] ()
#52263	0x000000018466fcac in -[NSApplication run] ()
#52264	0x000000018464171c in NSApplicationMain ()
#52265	0x0000000104b63ab8 in main at /Users/lugos/udev/manicmind/LookAtThat/LookAtThat_AppKit/AppDelegate.swift:14
#52266	0x0000000181db1450 in start ()

I'm calling SwiftTrace.traceInstances(ofClass: CodeSheetVisitor.self), but the crash is occurring in a static initialization of a different object, WordNodeBuilder. For some more context, is a SwftUI based up, which happens to use @ObserverableObject for a root data dependency. I'm thinking something about how the accessors are handled with these property wrappers may be the issue.

// SwiftUI view with property wrapper
struct MacAppRootView: View {
    @ObservedObject var library: SceneLibrary = SceneLibrary.global
    // ...
}

// Static object
class SceneLibrary: ObservableObject, MousePositionReceiver {
    // <!> Static init on class load / dereference...
    public static let global = SceneLibrary()

    // <!> ... causes local init of field, which causes crashes
    let wordNodeBuilder = WordNodeBuilder()

@johnno1962
Copy link
Owner

But can you tell me the signature of the method where it recurses?

@tikimcfee
Copy link
Contributor Author

Sorry, took me a minute to figure out what I needed to do for that. Is this is what you're after? :

Optional(<NSMethodSignature: 0x90317a6d4b15fd5f>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (v) 'v'
        flags {}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 0, size adjust = 0}
        memory {offset = 0, size = 0}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R0 = {}
Optional(<NSMethodSignature: 0x90317a6d4b15fd5f>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (v) 'v'
        flags {}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 0, size adjust = 0}
        memory {offset = 0, size = 0}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R1 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R2 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R3 = {}
() $R4 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R5 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R6 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R7 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R8 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R9 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R10 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R11 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R12 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R13 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)
() $R14 = {}
Optional(<NSMethodSignature: 0x90317a6d4b157e27>
    number of arguments = 2
    frame size = 224
    is special struct return? NO
    return value: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 0: -------- -------- -------- --------
        type encoding (@) '@'
        flags {isObject}
        modifiers {}
        frame {offset = 0, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
    argument 1: -------- -------- -------- --------
        type encoding (:) ':'
        flags {}
        modifiers {}
        frame {offset = 8, offset adjust = 0, size = 8, size adjust = 0}
        memory {offset = 0, size = 8}
)

Stringified:

+[Swift._SwiftObject initialize] -> v16@0:8
() $R0 = {}
+[Swift._SwiftObject initialize] -> v16@0:8
() $R1 = {}
-[_TtCs12_SwiftObject self] -> @16@0:8
() $R2 = {}
-[_TtCs12_SwiftObject self] -> @16@0:8
() $R3 = {}
-[_TtCs12_SwiftObject self] -> @16@0:8
() $R4 = {}
-[_TtCs12_SwiftObject self] -> @16@0:8
() $R5 = {}
-[_TtCs12_SwiftObject self] -> @16@0:8

I also saw a few blocks like this that may be different behavior, but don't really have a good clue as to why that's going on:

-[_TtCs12_SwiftObject self] -> @16@0:8
() $R1610 = {}
() $R1611 = {}
() $R1612 = {}
() $R1613 = {}
() $R1614 = {}
() $R1615 = {}
() $R1616 = {}
() $R1617 = {}
() $R1618 = {}
() $R1619 = {}
() $R1620 = {}
() $R1621 = {}
() $R1622 = {}
() $R1623 = {}
() $R1624 = {}
() $R1625 = {}
() $R1626 = {}
() $R1627 = {}
() $R1628 = {}
() $R1629 = {}
() $R1630 = {}
() $R1631 = {}
() $R1632 = {}
() $R1633 = {}
() $R1634 = {}
() $R1635 = {}
() $R1636 = {}
() $R1637 = {}
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
-[_TtCs12_SwiftObject self] -> @16@0:8
() $R1638 = {}
-[_TtCs12_SwiftObject self] -> @16@0:8

I captured this by sticking a breakpoint on let threadLocal = ThreadLocal.current() in onEntry and having it run:
expr -- print(swizzle.signature) / expr -- print(swizzle.methodSignature)

@johnno1962
Copy link
Owner

Thanks for the info. Looks like there is an Objective-C method named "self" that shouldn't get swizzled. Can you try adding that to the defaultMethodExclusions regular expression in SwiftTrace.swift:125 after "class" and before "description".

@johnno1962
Copy link
Owner

johnno1962 commented Jun 15, 2021

If you don't see what I mean, I've created a branch add-self-method on the repo with the change you can use with SPM.

@tikimcfee
Copy link
Contributor Author

I just gave this a shot on that branch and my fork and it seems to work great! Thanks one more time for helping troubleshoot this.

I may have a few more questions in a bit, specifically about output formatting or skipping certain parameters prints. For example, I've got a function with a param whose string description is a massive formatted string, meaning the log gets filled up with big unhelpful blocks. I figured something like that isn't an issue, and more a general usage question or feature request potentially.

To that end, I can Close this if you're comfortable with that additional branch as a solution, and either open another issue with questions, or can DM you directly on some client. Just let me know either way.

Cheers!

@johnno1962
Copy link
Owner

Great! Thanks for raising the issue. You can't filter individual arguments or types but you can filter which methods get swizzled before applying the trace with the method(Inclusion/Exclusion)Pattern static property. There is also real time filtering using the traceFilter(Include/Exclude) properties which are all regex patterns. Closing this now. Will release to main soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants