Is URLSession actually working on Linux


(Georgios Moschovitis) #1

I implemented a simple RSS feed aggregator. I used code like...

let data = try! Data(contentsOf: feedURL)

or

let session = URLSession(configuration: URLSessionConfiguration.default)
let task = session.dataTask(with: url, completionHandler: completionHandler)
task.resume()

...to fetch the data.

While my application worked perfectly when running on macOS, when I tried to run
it on Ubuntu it started crashing randomly with errors like...

*** Error in `bin/….': double free or corruption (fasttop): 0x00007f3880000ff0 ***
Aborted

or

Illegal instruction

etc.

When I switched to KituraRequest (in place of URLSession), the application started
running correctly on Ubuntu as well.

Are there any issues with the implementation of Foundation for Linux?

-g.

PS: I am using swift 4.0


(Geordie J) #2

I implemented a simple RSS feed aggregator. I used code like...

let data = try! Data(contentsOf: feedURL)

or

let session = URLSession(configuration: URLSessionConfiguration.default)
let task = session.dataTask(with: url, completionHandler:
completionHandler)
task.resume()

...to fetch the data.

While my application worked perfectly when running on macOS, when I tried
to run
it on Ubuntu it started crashing *randomly* with errors like...

*** Error in `bin/….': double free or corruption (fasttop):
0x00007f3880000ff0 ***
Aborted

or

Illegal instruction

etc.

I haven't seen it myself but I've heard from colleagues that we ran into
the same issues on Android. Foundation depends on libcurl (on Linux at
least?), so we're just going to make our own basic libcurl wrapper that
looks and acts like URLSession until the Foundation one works.

When I switched to KituraRequest (in place of URLSession), the application
started
running correctly on Ubuntu as well.

KituraRequest uses libcurl too, but its dependency tree is too complex for
us to use on Android.

Are there any issues with the implementation of Foundation for Linux?

tldr; Pretty sure, yes.

-g.

PS: I am using swift 4.0

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

-g

···

2017-10-03 20:10 GMT+02:00 Georgios Moschovitis via swift-users < swift-users@swift.org>:


(Alex Blewitt) #3

2017-10-03 20:10 GMT+02:00 Georgios Moschovitis via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>>:
I implemented a simple RSS feed aggregator. I used code like...

let data = try! Data(contentsOf: feedURL)

or

let session = URLSession(configuration: URLSessionConfiguration.default)
let task = session.dataTask(with: url, completionHandler: completionHandler)
task.resume()

...to fetch the data.

While my application worked perfectly when running on macOS, when I tried to run
it on Ubuntu it started crashing randomly with errors like...

*** Error in `bin/….': double free or corruption (fasttop): 0x00007f3880000ff0 ***
Aborted

There were some issues which were fixed on the swift-4 branch but which didn't make it in before the swift 4.0 release was cut. These fixes will be in the next point release of Swift.

Have you tried the code with the latest nightly build to verify whether that has fixed the issue you're seeing?

Are there any issues with the implementation of Foundation for Linux?

tldr; Pretty sure, yes.

There has been a reasonable amount of work put in recently, particularly with Data and URLSession.

You can have a look at the list of open issues for Foundation on Linux:

https://bugs.swift.org/issues/?jql=status%20in%20(Open%2C%20"In%20Progress"%2C%20Reopened)%20AND%20component%20%3D%20Foundation

Note that some of the issues may have been recently closed but not made it into a release.

One of my colleagues recently fixed an issue with concurrent data races, which has a similar effect to the one you're describing but may not be the same:

https://bugs.swift.org/browse/SR-5936

Alex

···

On 3 Oct 2017, at 19:15, Geordie Jay via swift-users <swift-users@swift.org> wrote:


(Georgios Moschovitis) #4

There has been a reasonable amount of work put in recently, particularly with Data and URLSession.

You can have a look at the list of open issues for Foundation on Linux:

https://bugs.swift.org/issues/?jql=status%20in%20(Open%2C%20"In%20Progress"%2C%20Reopened)%20AND%20component%20%3D%20Foundation <https://bugs.swift.org/issues/?jql=status%20in%20(Open%2C%20"In%20Progress"%2C%20Reopened)%20AND%20component%20%3D%20Foundation>

Note that some of the issues may have been recently closed but not made it into a release.

Good to know that someone is working on those issues!

thanks,
-g.


(Georgios Moschovitis) #5

I am wondering, is there an ETA for 4.0.1 ?

-g.

···

On 5 Oct 2017, at 8:58 PM, Georgios Moschovitis <george.moschovitis@icloud.com> wrote:

There has been a reasonable amount of work put in recently, particularly with Data and URLSession.

You can have a look at the list of open issues for Foundation on Linux:

https://bugs.swift.org/issues/?jql=status%20in%20(Open%2C%20"In%20Progress"%2C%20Reopened)%20AND%20component%20%3D%20Foundation <https://bugs.swift.org/issues/?jql=status%20in%20(Open%2C%20"In%20Progress"%2C%20Reopened)%20AND%20component%20%3D%20Foundation>

Note that some of the issues may have been recently closed but not made it into a release.

Good to know that someone is working on those issues!

thanks,
-g.


(Alex Blewitt) #6

I'm not aware of there being an ETA, but according to https://swift.org/download/ last year Swift 3.0 was released on September 13, 2016 and then a subsequent Swift 3.0.1 was released on October 28, 2016.

Alex

···

On 5 Oct 2017, at 19:18, Georgios Moschovitis <george.moschovitis@icloud.com> wrote:

I am wondering, is there an ETA for 4.0.1 ?


(Renan Jegouzo) #7

I see you want to use swift on android, do you have a working swift build chain for android ?


(Geordie J) #8

Try github.com/flowkey/swift-android-toolchain and let me know if you run into any issues!