Coder Social home page Coder Social logo

Comments (9)

helje5 avatar helje5 commented on July 22, 2024

This is with Xcode 7.1? I guess we need a branch for Swift 0.2.1.

from swiftsockets.

Danappelxx avatar Danappelxx commented on July 22, 2024

Perhaps, but that would mess things up with Carthage & Cocoapods. This fix shouldn't break any old version of Swift since it's only changing nil to be an empty closure, so I don't see why creating a new branch would be necessary in this case.

from swiftsockets.

helje5 avatar helje5 commented on July 22, 2024

Well, passing in NULL aka DISPATCH_DATA_DESTRUCTOR_DEFAULT is the intended thing here. That nil cannot be used is likely a bug in Swift (well, in the tagging of the API). Need to review this.

from swiftsockets.

helje5 avatar helje5 commented on July 22, 2024

Passing in {} is wrong and quite likely crashes the program. I'll test it with 7.1b and file a Radar with Apple later on.

from swiftsockets.

helje5 avatar helje5 commented on July 22, 2024

Works fine for me as-is in Xcode 7.1 (7B91b). What version do you use?

from swiftsockets.

Danappelxx avatar Danappelxx commented on July 22, 2024

I'm on Xcode 7.1 Beta (7B75). Could you explain why passing {} will cause it to crash? Could you give me an example which should crash it so that I can test it? Thanks.

from swiftsockets.

Danappelxx avatar Danappelxx commented on July 22, 2024

I'm downloading Xcode 7.2 Beta (just released today I think) and test passing nil there. If the issue persists I think this issue should be reopened.

from swiftsockets.

helje5 avatar helje5 commented on July 22, 2024

You might want to upgrade to the 7.1 release.

Passing in DISPATCH_DATA_DESTRUCTOR_DEFAULT (nil) tells GCD to copy the memory buffer being passed in (and maintain it internally).

The buffer being passed into the asyncWrite() function is temporary (conceptually on the stack) and will be gone eventually. If you pass a free-handler-block to GCD (instead of nil) you guarantee that the ptr being passed in will stay valid until that free-block is called. Which is wrong here, as the stack buffer will disappear or become corrupt.

As with all async stuff it can be hard to repro. The buffer may still be kinda valid and just have a few corruptions etc.

P.S.: This is just another reason why SwiftSockets is not really for production but more of a demo. Production software should use GCD channels and not copy any memory.

from swiftsockets.

Danappelxx avatar Danappelxx commented on July 22, 2024

Thanks for explaining that! Issue disappeared on newest version of Xcode (7.2 beta), so I guess this should remain closed.

from swiftsockets.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.