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

Bad access error when running on device #100

Closed
flowbe opened this issue May 7, 2019 · 11 comments
Closed

Bad access error when running on device #100

flowbe opened this issue May 7, 2019 · 11 comments
Assignees
Labels
more info needed Not enough details available to proceed

Comments

@flowbe
Copy link
Contributor

flowbe commented May 7, 2019

After working on simulator on my app, I wanted to test it on my iPad but I have a EXC_BAD_ACCESS on line 382 of XMLDecoderImplementation.swift. This error isn't present when I run the app on the simulator.

I run the app on a 2017 iPad with iOS 12.1.4 and for the simulator I used the iPad Pro 11" with iOS 12.2.

@MaxDesiatov
Copy link
Collaborator

Hi @TheFlow95, can you please attach any code and XML snippets that reproduce this for you? Thanks!

@flowbe
Copy link
Contributor Author

flowbe commented May 8, 2019

The code I used is the same as CoreXLSX:

func parseEntry<T: Decodable>(_ path: String, _ type: T.Type) throws -> T {
    guard let entry = archive[path] else {
        throw Error.archiveEntryNotFound
    }

    var data = Data()
    _ = try archive.extract(entry, bufferSize: bufferSize) {
        data.append($0)
    }

    return try decoder.decode(type, from: data)
}

And when this method is executed it produces the error on the device.

@MaxDesiatov
Copy link
Collaborator

MaxDesiatov commented May 8, 2019

@TheFlow95 would you be able to attach the file and the project that reproduce this for you? I'm inclined to think this has something to do with project settings or the file. I'm not able to reproduce it with the CoreXLSX Example project and Xcode 10.2 on 2017 iPad Pro 10.5-inch and iPhone X both running iOS 12.2.

@MaxDesiatov MaxDesiatov added the more info needed Not enough details available to proceed label May 8, 2019
@flowbe
Copy link
Contributor Author

flowbe commented May 9, 2019

I cannot attach my project but I am working on a framework that includes XMLCoder and the issue happens when I use the framework inside an app. So here are the steps to reproduce:

  1. Create a framework with XMLCoder in it
  2. Create an app and add the framework to it
  3. Run this code in the app:
let path = Bundle.main.resourceURL!.appendingPathComponent("sample.pptx").path
        
if let swiftPresentationML = SwiftPresentationML(filepath: path) {
    do {
        guard let entry = swiftPresentationML.archive["ppt/presentation.xml"] else {
            fatalError()
        }
                
        var data = Data()
        _ = try swiftPresentationML.archive.extract(entry) {
            data.append($0)
        }
                
        print(try XMLDecoder().decode(PresentationXML.self, from: data))
    }
    catch {
        print(error)
    }
}
else {
    fatalError()
}

I can reproduce with any PowerPoint file but I'm attaching one here

Thanks for you help!

sample.pptx

@MaxDesiatov
Copy link
Collaborator

Thank you for the file. It's really great to see the interest in .pptx format support. I'm probably going to rename CoreXLSX repository to CoreOffice in the next release after I add new CorePPT module. It's now in CoreOffice/CoreXLSX#63 PR that I will use to create a reproduction case.

@MaxDesiatov
Copy link
Collaborator

Hey @TheFlow95, I've just pushed .pptx support to the Example project of pptx branch, could you please try running that project on your devices? It requires running pod install in that directory before building.

That project builds and runs without a problem on both of my devices I listed in previous comments, it displays structures of .xlsx and your sample.pptx file in different tabs. Interesting to hear if this example project has any substantial difference from your project? I look forward to hearing from you.

@flowbe
Copy link
Contributor Author

flowbe commented May 14, 2019

Hello @MaxDesiatov! I tried your example project on my device and it does work.

I am starting to think this is some kind of stack overflow problem, because I load in memory the file with structs. Do you know things about it?

@MaxDesiatov
Copy link
Collaborator

MaxDesiatov commented May 14, 2019

Hi @TheFlow95, thanks for the update. I don't know of any possible stack overflow problems in CoreXLSX or XMLCoder. I hope the full stack trace of the crash (if sharing your isolated project is not possible) could point in the right direction. Would you mind sharing that stack trace here? Or you could share the project to xmlcoder@desiatov.com

@flowbe
Copy link
Contributor Author

flowbe commented May 14, 2019

As a workaround, I changed my structs into classes but I don't know if it's a good thing to do (memory seems okay)…
I'm going to try sharing the stack trace but I also found out that there are many different stack traces leading to the ”Bad access” error.

@MaxDesiatov
Copy link
Collaborator

Hi @TheFlow95, is this still reproducible for you? Can this issue be closed otherwise?

@MaxDesiatov
Copy link
Collaborator

As this issue hasn't been updated for quite a while, I'm closing it as outdated. Please feel free to reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info needed Not enough details available to proceed
Projects
None yet
Development

No branches or pull requests

2 participants