Comments (9)
This is with Xcode 7.1? I guess we need a branch for Swift 0.2.1.
from swiftsockets.
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.
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.
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.
Works fine for me as-is in Xcode 7.1 (7B91b). What version do you use?
from swiftsockets.
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.
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.
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.
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)
- Read can block if a read block has the same size as the buffer HOT 2
- Error 35 on socket.read() HOT 4
- Crash with EXC_ARM_DA_ALIGN in iOS7 release version HOT 6
- Push v0.20.2 to CocoaPods HOT 1
- Xcode does not have an iOS framework target HOT 1
- Provide a non-blocking connect()
- Support the new Swift package manager HOT 9
- Support Linux Swift HOT 3
- support SSL/TLS? HOT 3
- Convert Xcode project to use xcconfig files to avoid per-arch targets
- How do I print out a client's message on server side? HOT 1
- Swift 3 support HOT 9
- Support Xcode 8 / Swift 2.3. HOT 2
- Socket should be a generic Socket<T: SocketAddress> HOT 2
- Weird init() of sockaddr_in taking the port first, then the address. HOT 1
- CocoaPods? HOT 6
- ARIFetch Fails on String Conversion
- Without Foundation HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftsockets.