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

getData EXC_BAD_ACCESS #63

Open
treymcmeans opened this issue Jul 27, 2017 · 11 comments
Open

getData EXC_BAD_ACCESS #63

treymcmeans opened this issue Jul 27, 2017 · 11 comments

Comments

@treymcmeans
Copy link

Using the getData method, I am getting a random EXC_BAD_ACCESS on the lastQueryParameters = query line.

malloc: *** error for object 0x61800045c31e: Invalid pointer dequeued from free list

Here is the error from the console. I'm not sure if this is related to #15 or not? Thanks for your help. Let me know if you need more information.

  open func getData(_ key: String) -> Data? {
    let prefixedKey = keyWithPrefix(key)
    
    var query: [String: Any] = [
      KeychainSwiftConstants.klass       : kSecClassGenericPassword,
      KeychainSwiftConstants.attrAccount : prefixedKey,
      KeychainSwiftConstants.returnData  : kCFBooleanTrue,
      KeychainSwiftConstants.matchLimit  : kSecMatchLimitOne
    ]
    
    query = addAccessGroupWhenPresent(query)
    query = addSynchronizableIfRequired(query, addingItems: false)
    lastQueryParameters = query
    
    var result: AnyObject?
    
    lastResultCode = withUnsafeMutablePointer(to: &result) {
      SecItemCopyMatching(query as CFDictionary, UnsafeMutablePointer($0))
    }
    
    if lastResultCode == noErr { return result as? Data }
    
    return nil
  }

@evgenyneu
Copy link
Owner

evgenyneu commented Jul 28, 2017

Thanks for reporting. I have not seen this one before. Is it crashing consistently, can you reproduce the problem? If so, could you isolate this bug into a demo app and post here please, so I can try and debug it?

I googled the error text and found this stackoverflow discussion. They suggested changing deployment target. Not sure if that's relevant to your case.

@treymcmeans
Copy link
Author

treymcmeans commented Jul 28, 2017 via email

@evgenyneu
Copy link
Owner

A sample project would be great, thank you.

@juliorimo
Copy link

juliorimo commented Oct 9, 2017

This is happening to me many times when I try to use getData into an Operation.

*** error for object 0x101903620: pointer being freed was not allocated

KeychainSwift.swift line 169
specialized KeychainSwift.getData(String) -> Data?

And this is what I see in the console:
malloc: *** error for object 0x604000258d1e: Invalid pointer dequeued from free list *** set a breakpoint in malloc_error_break to debug

@evgenyneu
Copy link
Owner

This was probably fixed by this pull request.

@MouGABSI
Copy link

MouGABSI commented Mar 8, 2018

I am having the same problem with the last version and i am using iOS 11.
It does happen frequently.

@RamblinWreck77
Copy link

This happens to me as well. Here's the relevant info from the crashed thread:

Crashed: com.apple.main-thread
0  KeychainSwift                  0x101b30a7c (String, Any) (KeychainSwift.swift)
1  KeychainSwift                  0x101b2f36c _NativeDictionaryBuffer (KeychainSwift.swift)
2  KeychainSwift                  0x101b304e4 specialized KeychainSwift.getData(String) -> Data? (KeychainSwift.swift:171)
3  KeychainSwift                  0x101b2d820 KeychainSwift.getData(String) -> Data? (KeychainSwift.swift)

Error is:

Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x05ff2b7000000390

@evgenyneu
Copy link
Owner

@RamblinWreck77, @MouldiGABSI, thanks for reporting. There was a multithreading issue fixed since version 10 of the library. Make sure you are at version 10 at least.

@RamblinWreck77
Copy link

@evgenyneu My Apologies, I didn't mention the version.

This is on v11.0.0

@brow
Copy link

brow commented Jul 24, 2018

I'm encountering this crash with v11.0.0 on iOS 11. I noticed:

  • The crash did not occur when I was building keychain-swift with Carthage (as a dynamic framework), only once I started building keychain-swift with Cocoapods (as a static framework).
  • The crash occurs in a Release build, not in a Debug build, though I have not been able yet to deduce which build setting in particular is decisive.
  • The same crash occurs with KeychainAccess as well as with this library

@andre991
Copy link

Any solutions?

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

7 participants