Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

TestFlight logging crash intermittently with invalid handle #183

Open
tystol opened this issue Nov 21, 2013 · 1 comment
Open

TestFlight logging crash intermittently with invalid handle #183

tystol opened this issue Nov 21, 2013 · 1 comment

Comments

@tystol
Copy link

tystol commented Nov 21, 2013

I'm getting very weird intermittent app crashes on release builds of my app.

Nov 21 11:17:42 tyPhone AppName[6714] <Notice>: TestFlight: Checkpoint Passed - Some Checkpoint
Nov 21 11:17:42 tyPhone AppName[6714] <Notice>: SomeClass: DEBUG Some log message
Nov 21 11:17:42 tyPhone AppName[6714] <Error>: Stacktrace:
Nov 21 11:17:42 tyPhone AppName[6714] <Error>:   at <unknown> <0xffffffff>
Nov 21 11:17:42 tyPhone AppName[6714] <Error>:   at (wrapper managed-to-native) MonoTouch.TestFlight.TestFlight.WrapperTfLog (intptr) <0xffffffff>
Nov 21 11:17:42 tyPhone AppName[6714] <Error>:   at MonoTouch.TestFlight.TestFlight.Log (string,object[]) <0x0006b>
Nov 21 11:17:42 tyPhone AppName[6714] <Error>:   at AppName.TestFlightLog.Log (string,object) <0x0008b>

Is that 0xffffffff the address of the NSString parameter passed to the WrapperTfLog method? Or is it the address of the method itself?

If its the first, then it appears that the mss.Handle is returning an invalid 0xffffffff handle on the newly constructed NSString. Very weird.

If the latter, it makes no sense as this is not the first log call. The app has been logging just fine directly before this failure.

@tystol
Copy link
Author

tystol commented Nov 25, 2013

I worked around this by calling the native method directly, using a similar implementation but without the using statement and a pointer check. It now works 100% of the time (i.e. I'm getting all the logs, its never missing the if check) so I therefor believe its something to do with the using statement - possibly a CLR optimisation that's not realising the Handle accessor requires the string to be kept around for the lifetime of the using statement?

    [DllImport("__Internal", EntryPoint = "TFLog")]
    private extern static void WrappedTFLog(IntPtr handle);
    private static void Log (string msg)
    {
        var nss = new NSString(msg);
        var handle = nss.Handle;
        if ( handle != (IntPtr) 0xffffffff )
            WrappedTFLog(nss.Handle);
    }

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

No branches or pull requests

1 participant