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

Crashes when dequeueNext #254

Closed
g-bourachot opened this issue Oct 25, 2018 · 17 comments
Closed

Crashes when dequeueNext #254

g-bourachot opened this issue Oct 25, 2018 · 17 comments

Comments

@g-bourachot
Copy link

g-bourachot commented Oct 25, 2018

Crashlytics is telling me we've got crashes on our app due to SwiftMessages.

Here is the stack :
Crashed: com.apple.main-thread
0 (Missing) 0x300920bd4 (Missing)
1 (Missing) 0x300920bd4 (Missing)
2 SwiftMessages 0x1009156c8 closure #1 in SwiftMessages.dequeueNext() (SwiftMessages.swift:547)
3 SwiftMessages 0x1009105f8 thunk for @escaping @callee_guaranteed () -> () ()
4 libdispatch.dylib 0x186dab6c8 _dispatch_call_block_and_release + 24
5 libdispatch.dylib 0x186dac484 _dispatch_client_callout + 16
6 libdispatch.dylib 0x186d589ec _dispatch_main_queue_callback_4CF$VARIANT$mp + 1068
7 CoreFoundation 0x1873021bc CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 12
8 CoreFoundation 0x1872fd084 __CFRunLoopRun + 1964
9 CoreFoundation 0x1872fc5b8 CFRunLoopRunSpecific + 436
10 GraphicsServices 0x189570584 GSEventRunModal + 100
11 UIKitCore 0x1b4178bc8 UIApplicationMain + 212
12 snapSchool 0x100520814 main (AppDelegate.swift:25)
13 libdyld.dylib 0x186dbcb94 start + 4

I haven't reproduced the crash yet

XCode10, Swift 4.2, Branch : work/swift4.2

My code calling the lib :

func presentToastForFinishedTask(tasks : [PostQueue.TaskInfo]) {
        for task in tasks {
            let view = MessageView.viewFromNib(layout: .messageView)
            view.configureTheme(.success)
            switch task.type {
            case .answer(_, let title):
                let body = String(format : NSLocalizedString("toast.answer.finished",comment: ""),title)
                view.configureContent(body: body)
                view.titleLabel?.isHidden = true
            case .exam(title: _):
                fatalError("not supported")
            }
            view.button?.isHidden = true

            var config = SwiftMessages.Config()
            config.duration = .seconds(seconds: 5)

            SwiftMessages.show(config : config, view: view)
        }
    }
@wtmoose
Copy link
Member

wtmoose commented Oct 25, 2018

Whats the exception type? Whats the platform? What version of iOS? What does your SwiftMessages code look like?

@g-bourachot
Copy link
Author

The exception type is : EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x000000030451cbd4
Devices mainly iPhone, but 5% iPad
Version : iOS 12 and iOS 11
My SwiftMessages code is above, unless I didn't understand what you are asking for :D

@wtmoose
Copy link
Member

wtmoose commented Nov 14, 2018

The KERN_INVALID_ADDRESS exception means that the code is trying to reference a deallocated memory. However, I don't see anything suspicious in the code and nobody else has reported this crash, which makes me think your app is in a bad state for reasons unrelated to SwiftMessages.

I don't see how I can help with this unless you provide reproduction steps.

@ybeapps
Copy link

ybeapps commented Nov 23, 2018

I have a similar crash too with that code.

let msgView = MessageView.viewFromNib(layout: .messageView)
msgView.configureTheme(.info, iconStyle: .light)
msgView.button?.removeFromSuperview()
msgView.configureContent(
            title: "Title of message box",
            body: "Body")
msgView.bodyLabel?.textAlignment = .natural
        
var config = SwiftMessages.Config()
config.presentationStyle = .center
config.duration = .automatic
config.dimMode = .gray(interactive: true)
        
SwiftMessages.show(config: config, view: msgView) // <----- CRASH HERE

That code worked without any changes.
The change is that I just updated Xcode + SwiftMessages (from 4.1.4 to 6.0.1) + pod install
Not crashing in older version
Crashing in this version
But when I'm taking that code to a clean empty project it works well
I really don't know what to do

When I'm debugging I'm getting to:

My code:
SwiftMessages.show(config: config, view: msgView)Your code:
SwiftMessages.swift line 544
-> DispatchQueue.main.async { [weak self] in
I've added a breakpoint inside the closure but it won't get there
screen shot 2018-11-23 at 9 06 20

When I'm tapping "Continue" this what I get:
screen shot 2018-11-23 at 9 08 36
screen shot 2018-11-23 at 9 08 51

Please help me debug it.

@wtmoose
Copy link
Member

wtmoose commented Nov 23, 2018

If anyone can provide repro steps or send me a project that crashes, I’ll take a look.

@ybeapps
Copy link

ybeapps commented Nov 25, 2018

It’s a bit hard to reproduce this in a clean environment. I tried, but it didn’t crash.
Does a crash log helps you?

@ybeapps
Copy link

ybeapps commented Nov 25, 2018

The interesting part is the sub-type of the crash: EXC_ARM_DA_ALIGN

I don’t know why is this happening, my code is Swift.
And it crashes in SwiftMessages.
So it’s not clear

Check out this: http://www.splinter.com.au/what-do-do-with-excarmdaalign-on-an-iphone-ap/

And this: https://stackoverflow.com/questions/15925287/exc-arm-da-align-crash

@ybeapps
Copy link

ybeapps commented Nov 25, 2018

{"app_name":"Theory-iOS-Free","timestamp":"2018-11-24 23:41:42.77 +0200","app_version":"4.8","slice_uuid":"70a131e5-a628-334d-86ca-222d3c5ac893","adam_id":0,"build_version":"4.8.1","bundleID":"com.ybe.theory.free","share_with_app_devs":true,"is_first_party":false,"bug_type":"109","os_version":"iPhone OS 12.1 (16B92)","incident_id":"5B05C4CE-64ED-4383-9940-F2538FE81393","name":"Theory-iOS-Free"}
Incident Identifier: 5B05C4CE-64ED-4383-9940-F2538FE81393
CrashReporter Key: 1bd73e7b72eb3dc007603562d9cb3ae302370298
Hardware Model: iPhone8,4
Process: Theory-iOS-Free [422]
Path: /private/var/containers/Bundle/Application/4EF701BC-6EE8-4A17-BCE0-2C47A1A6C0D7/Theory-iOS-Free.app/Theory-iOS-Free
Identifier: com.ybe.theory.free
Version: 4.8.1 (4.8)
Code Type: ARM-64 (Native)
Role: Non UI
Parent Process: launchd [1]
Coalition: com.ybe.theory.free [466]

Date/Time: 2018-11-24 23:41:42.5806 +0200
Launch Time: 2018-11-24 23:40:59.6414 +0200
OS Version: iPhone OS 12.1 (16B92)
Baseband Version: 7.21.00
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Subtype: EXC_ARM_DA_ALIGN at 0xb2f81e0488302008
VM Region Info: 0xb2f81e0488302008 is not in any region. Bytes after previous region: 12896090526514683913
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
MALLOC_NANO 0000000280000000-00000002a0000000 [512.0M] rw-/rwx SM=PRV
--->
UNUSED SPACE AT END

Termination Signal: Bus error: 10
Termination Reason: Namespace SIGNAL, Code 0xa
Terminating Process: exc handler [422]
Triggered by Thread: 0

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libswiftCore.dylib 0x00000001019eb378 0x101728000 + 2896760
1 libswiftCore.dylib 0x00000001019d657c 0x101728000 + 2811260
2 libswiftCore.dylib 0x00000001019d657c 0x101728000 + 2811260
3 SwiftMessages 0x00000001014ce388 0x1014a0000 + 189320
4 SwiftMessages 0x00000001014ce5a0 0x1014a0000 + 189856
5 SwiftMessages 0x00000001014e4e70 0x1014a0000 + 282224
6 Theory-iOS-Free 0x000000010037b160 0x1002f0000 + 569696
7 Theory-iOS-Free 0x000000010037aa38 0x1002f0000 + 567864
8 Theory-iOS-Free 0x000000010037bac8 0x1002f0000 + 572104
9 Theory-iOS-Free 0x00000001003b6a74 0x1002f0000 + 813684
10 Theory-iOS-Free 0x00000001003b5fc0 0x1002f0000 + 810944
11 Theory-iOS-Free 0x00000001003b6af8

@ybeapps
Copy link

ybeapps commented Nov 25, 2018

Ok, I changed the position of my code (in my original project) and got the faulty stack trace of the SwiftMessages

I'm attaching the output of "bugreport" command in lldb
You have stack trace, registers, threads, system, everything you need...

BUGREPORT.txt

@ybeapps
Copy link

ybeapps commented Nov 25, 2018

this is the crashing code:

static func newInstance(windowLevel: UIWindow.Level?, config: SwiftMessages.Config) -> 
    WindowViewController {
            return config.windowViewController?(windowLevel, config) ?? WindowViewController(windowLevel: windowLevel, config: config)
    }

This works:

WindowViewController(windowLevel: windowLevel, config: config)

This crashes:

config.windowViewController?(windowLevel, config)

See in lldb:

(lldb) po WindowViewController(windowLevel: windowLevel, config: config)
<SwiftMessages.WindowViewController: 0x7fdc5f67c100>

(lldb) po config.windowViewController?(windowLevel, config)
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=2, address=0x7fdc5f409230).
The process has been returned to the state before expression evaluation.```

@ybeapps
Copy link

ybeapps commented Nov 25, 2018

Well, Apparently there are several issues.
When I changed the code to:

static func newInstance(windowLevel: UIWindow.Level?, config: SwiftMessages.Config) -> 
    WindowViewController {
            return WindowViewController(windowLevel: windowLevel, config: config)
    }

IT WORKS!!!!

But then I restore my code to its original place -> it crashes again..
Maybe there is a problem in my compilation flags?
bitcode?
Something that I may done and I have no understanding in it?

@wtmoose
Copy link
Member

wtmoose commented Nov 25, 2018

My best guess is your app is an a bad state for some reason it just happens to crash in SwiftMessages code. I don't think there's anything wrong with the lines that are crashing. You can send me your app source code directly and I'll take a look when I get time (I'm extremely busy at the moment), but I'm not going to be able to solve this for you in this forum. You might have luck on Stack Overflow.

@ybeapps
Copy link

ybeapps commented Nov 25, 2018 via email

@ybeapps
Copy link

ybeapps commented Nov 26, 2018

Looks like I find the issue.
My project is Swift 4
Swift Messages is Swift 4.2

My test project is Swift 4.2 also, that's why it's working
When I change it to Swift 4 - CRASH!!!!! BOOM!!!!

@ybeapps
Copy link

ybeapps commented Nov 26, 2018

Well I upgraded my project to Swift 4.2 and everything works just great!!!

@wtmoose
Copy link
Member

wtmoose commented Nov 26, 2018

@ybeapps Glad you fixed it. That's a weird one. Others with the Swift version mismatch got a compile error: #229

@wtmoose
Copy link
Member

wtmoose commented Nov 29, 2018

@g-bourachot Can you check if your app or any of its dependencies are Swift 4.1?

@wtmoose wtmoose closed this as completed Dec 4, 2018
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

3 participants