Segmentation fault with Swift 5.0 on Linux

linux
bug
#1

Hey, is there anyone who faced with Segmantation fault errors with Swift 5.0-Release on Linux?
My Vapor 3 project works well with Swift 4.2, but with Swift 5.0 it fails in several places with Segmentation fault error absolutely unfair. Looks like a Swift 5.0 compiler bug on Linux.

Idk how to debug segmentation fault, so I switched back to Swift 4.2 and my project works well again.

(Johannes Weiss) #2

Does it segfault when running your vapor app or when compiling it?

If it’s the former, you should file a Vapor bug and if it’s the latter, please file a bugs.swift.org bug.

In any case, could you send all the output from the command that crashes here?

Thanks, Johannes

#3

Johannes, thank you for quick reply,

This segfault happens while my app is already compiled and running.

One of places where it crashes in my app is a simple line slot.status = .active, the bigger piece of code looks like this

return req.transaction(on: .psql) { conn in
    slot.status = .active // crashes here
    return slot.save(on: conn).transform(to: .ok)
}

Just in case I already tried to remove .build folder and Package.resolved, but have no luck, it still fails with Swift 5.0, although it works stable with Swift 4.2, so it looks like it's not a bug of Vapor.

It looks like I should file a bug on bugs.swift.org, right?

(Johannes Weiss) #4

@MikeIsaev this is probably a bug in Vapor or your app. So I'd start with filing a Vapor bug on github/vapor or reaching out to the Vapor folks on their Discord Server.

Please include the whole stack trace and all the messages that you received.

#5

How it may be a bug in my code or Vapor's code while it works well with Swift 4.2? I just don't understand that.

#6

I see only segmentation fault and that's it. How to print the whole stack trance on linux? I'm running app's binary either manually in terminal like this ./.build/x86_64-unknown-linux/debug/Run or through supervisor and in both cases I see only segmentation fault error.

(Johannes Weiss) #7

I'm not saying you or Vapor did but you or Vapor may have written something illegal that happened to work on Swift 4.2.

Can you do

lldb ./.build/x86_64-unknown-linux/debug/Run

and as soon as you see

(lldb)

type run and press Enter. Once it then crashes in lldb, type bt and press Enter. That should output the stack trace and some other info.

After that, reproduce the bug and you should see a lot more information.

#8

Tried to run my app under lldb like you suggested above lldb ./.build/x86_64-unknown-linux/debug/Run and getting this on one of my endpoints which works well if compiled with Swift 4.2 but fails with Swift 5

Process 3749 stopped
* thread #7, name = 'NIO-ELT-#0', stop reason = signal SIGSEGV: invalid address (fault address: 0x18)
    frame #0: 0x00007ffff75cfd90 libFoundation.so`CFLocaleGetIdentifier
libFoundation.so`CFLocaleGetIdentifier:
->  0x7ffff75cfd90 <+0>: movq   0x18(%rdi), %rax
    0x7ffff75cfd94 <+4>: retq
    0x7ffff75cfd95:      nopw   %cs:(%rax,%rax)
    0x7ffff75cfd9f:      nop
Target 0: (Run) stopped.

then I hit bt

(lldb) bt
* thread #7, name = 'NIO-ELT-#0', stop reason = signal SIGSEGV: invalid address (fault address: 0x18)
  * frame #0: 0x00007ffff75cfd90 libFoundation.so`CFLocaleGetIdentifier
    frame #1: 0x00007ffff75b9b24 libFoundation.so`__CFCalendarSetupCal + 20
    frame #2: 0x00007ffff75bbe40 libFoundation.so`_CFCalendarDecomposeAbsoluteTimeV + 48
    frame #3: 0x00007ffff7388747 libFoundation.so`Foundation.NSCalendar.components(_: Foundation.NSCalendar.Unit, from: Foundation.Date) -> Foundation.DateComponents + 935
    frame #4: 0x00007ffff725f456 libFoundation.so`partial apply forwarder for closure #1 (Foundation.NSCalendar) -> Foundation.DateComponents in Foundation.Calendar.dateComponents(_: Swift.Set<Foundation.Calendar.Component>, from: Foundation.Date) -> Foundation.DateComponents + 54
    frame #5: 0x00007ffff725f494 libFoundation.so`partial apply forwarder for reabstraction thunk helper from @callee_guaranteed (@guaranteed Foundation.NSCalendar) -> (@owned Foundation.DateComponents, @error @owned Swift.Error) to @escaping @callee_guaranteed (@guaranteed Foundation.NSCalendar) -> (@out Foundation.DateComponents, @error @owned Swift.Error) + 20
    frame #6: 0x00007ffff724813a libFoundation.so`Foundation._MutableHandle.map<A>((A) throws -> A1) throws -> A1 + 74
    frame #7: 0x00007ffff725917b libFoundation.so`Foundation.Calendar.dateComponents(_: Swift.Set<Foundation.Calendar.Component>, from: Foundation.Date) -> Foundation.DateComponents + 155
    frame #8: 0x00005555556f901a Run`static Date.findNearestDateBy(dayOfWeek=5, self=Foundation.Date) at Date+DayOfWeek.swift:8:53
    frame #9: 0x000055555569b919 Run`closure #1 in closure #1 in closure #1 in closure #1 in closure #1 in EventController.eventSlotApprove(slot=<unavailable>, city=<unavailable>, conn=<unavailable>, req=<unavailable>) at EventSlot+Approve.swift:12:51
    frame #10: 0x000055555569d26f Run`partial apply for closure #1 in closure #1 in closure #1 in closure #1 in closure #1 in EventController.eventSlotApprove(_:) at <compiler-generated>:0
    frame #11: 0x0000555555670279 Run`thunk for @escaping @callee_guaranteed (@guaranteed EventSlot) -> (@owned EventLoopFuture<HTTPResponseStatus>, @error @owned Error) at <compiler-generated>:0
    frame #12: 0x000055555569d2db Run`thunk for @escaping @callee_guaranteed (@guaranteed EventSlot) -> (@owned EventLoopFuture<HTTPResponseStatus>, @error @owned Error)partial apply at <compiler-generated>:0
    frame #13: 0x000055555587d220 Run`closure #1 in EventLoopFuture.flatMap<A>(expectation=0x00007fffd405aca0 -> 0x00005555563af828 full type metadata for App.EventSlot + 16, callback=0x000055555569d2c0 Run`reabstraction thunk helper from @escaping @callee_guaranteed (@guaranteed App.EventSlot) -> (@owned NIO.EventLoopFuture<NIOHTTP1.HTTPResponseStatus>, @error @owned Swift.Error) to @escaping @callee_guaranteed (@in_guaranteed App.EventSlot) -> (@owned NIO.EventLoopFuture<NIOHTTP1.HTTPResponseStatus>, @error @owned Swift.Error)partial apply forwarder with unmangled suffix ".24" at <compiler-generated>, promise=<unavailable>) at Future+Map.swift:50:34
    frame #14: 0x000055555587d3c9 Run`partial apply for closure #1 in EventLoopFuture.flatMap<A>(to:_:) at <compiler-generated>:0
    frame #15: 0x0000555555c06d1f Run`closure #1 in EventLoopFuture.whenSuccess(self=<unavailable>, callback=0x000055555587d390 Run`partial apply forwarder for closure #1 (A) -> () in (extension in Async):NIO.EventLoopFuture.flatMap<A>(to: A1.Type, _: (A) throws -> NIO.EventLoopFuture<A1>) -> NIO.EventLoopFuture<A1> at <compiler-generated>) at EventLoopFuture.swift:631:17
    frame #16: 0x0000555555c092c5 Run`partial apply for closure #1 in EventLoopFuture.whenSuccess(_:) at <compiler-generated>:0
    frame #17: 0x0000555555c00090 Run`thunk for @escaping @callee_guaranteed () -> (@owned CallbackList) at <compiler-generated>:0
    frame #18: 0x0000555555c0ec51 Run`thunk for @escaping @callee_guaranteed () -> (@owned CallbackList)partial apply at <compiler-generated>:0
    frame #19: 0x0000555555bffbe3 Run`thunk for @escaping @callee_guaranteed () -> (@out CallbackList) at <compiler-generated>:0
    frame #20: 0x0000555555c0edd1 Run`thunk for @escaping @callee_guaranteed () -> (@out CallbackList)partial apply at <compiler-generated>:0
    frame #21: 0x0000555555c01106 Run`CallbackList._run(self=<unavailable>) at EventLoopFuture.swift:108:32
    frame #22: 0x0000555555c017a4 Run`EventLoopPromise._resolve(value=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:192:37
    frame #23: 0x0000555555c0164c Run`EventLoopPromise.succeed(result=0x00007fffd405aca0 -> 0x00005555563af828 full type metadata for App.EventSlot + 16, self=<unavailable>) at EventLoopFuture.swift:171:9
    frame #24: 0x0000555555c08f21 Run`closure #1 in EventLoopFuture.cascade(v=<unavailable>, promise=<unavailable>) at EventLoopFuture.swift:766:25
    frame #25: 0x0000555555c08f9c Run`partial apply for closure #1 in EventLoopFuture.cascade(promise:) at <compiler-generated>:0
    frame #26: 0x0000555555c06a1d Run`closure #1 in EventLoopFuture._whenCompleteWithValue(callback=0x0000555555c08f80 Run`partial apply forwarder for closure #1 (NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> () in NIO.EventLoopFuture.cascade(promise: NIO.EventLoopPromise<A>) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:613:13
    frame #27: 0x0000555555c0eb95 Run`partial apply for closure #1 in EventLoopFuture._whenCompleteWithValue(_:) at <compiler-generated>:0
    frame #28: 0x0000555555c00734 Run`CallbackList._run(self=<unavailable>) at EventLoopFuture.swift:82:27
    frame #29: 0x0000555555c017a4 Run`EventLoopPromise._resolve(value=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:192:37
    frame #30: 0x0000555555c0164c Run`EventLoopPromise.succeed(result=0x00007fffd405aca0 -> 0x00005555563af828 full type metadata for App.EventSlot + 16, self=<unavailable>) at EventLoopFuture.swift:171:9
    frame #31: 0x0000555555c08f21 Run`closure #1 in EventLoopFuture.cascade(v=<unavailable>, promise=<unavailable>) at EventLoopFuture.swift:766:25
    frame #32: 0x0000555555c08f9c Run`partial apply for closure #1 in EventLoopFuture.cascade(promise:) at <compiler-generated>:0
    frame #33: 0x0000555555c06a1d Run`closure #1 in EventLoopFuture._whenCompleteWithValue(callback=0x0000555555c08f80 Run`partial apply forwarder for closure #1 (NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> () in NIO.EventLoopFuture.cascade(promise: NIO.EventLoopPromise<A>) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:613:13
    frame #34: 0x0000555555c0eb95 Run`partial apply for closure #1 in EventLoopFuture._whenCompleteWithValue(_:) at <compiler-generated>:0
    frame #35: 0x0000555555c0464b Run`EventLoopFuture._addCallback(callback=0x0000555555c0eb80 Run`partial apply forwarder for closure #1 () -> NIO.(CallbackList in _1CAEE0056AB83634CE1A29DE57BC300C) in NIO.EventLoopFuture.(_whenCompleteWithValue in _1CAEE0056AB83634CE1A29DE57BC300C)((NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> ()) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:597:16
    frame #36: 0x0000555555c04855 Run`EventLoopFuture._whenComplete(callback=0x0000555555c0eb80 Run`partial apply forwarder for closure #1 () -> NIO.(CallbackList in _1CAEE0056AB83634CE1A29DE57BC300C) in NIO.EventLoopFuture.(_whenCompleteWithValue in _1CAEE0056AB83634CE1A29DE57BC300C)((NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> ()) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:603:13
    frame #37: 0x0000555555c0681f Run`EventLoopFuture._whenCompleteWithValue(callback=0x0000555555c08f80 Run`partial apply forwarder for closure #1 (NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> () in NIO.EventLoopFuture.cascade(promise: NIO.EventLoopPromise<A>) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:612:9
    frame #38: 0x0000555555c04754 Run`EventLoopFuture.cascade(promise=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:761:9
    frame #39: 0x000055555587d284 Run`closure #1 in EventLoopFuture.flatMap<A>(expectation=0x00007fffd405aca0 -> 0x00005555563af828 full type metadata for App.EventSlot + 16, callback=0x00005555559efbb0 Run`partial apply forwarder for closure #4 (B) throws -> NIO.EventLoopFuture<B> in closure #1 (A.Connection) throws -> NIO.EventLoopFuture<B> in (extension in Fluent):Fluent.QueryBuilder< where A == B.Database, B: Fluent.Model>.update(_: B, originalID: Swift.Optional<B.ID>) -> NIO.EventLoopFuture<B> at <compiler-generated>, promise=<unavailable>) at Future+Map.swift:51:24
    frame #40: 0x000055555587d3c9 Run`partial apply for closure #1 in EventLoopFuture.flatMap<A>(to:_:) at <compiler-generated>:0
    frame #41: 0x0000555555c06d1f Run`closure #1 in EventLoopFuture.whenSuccess(self=<unavailable>, callback=0x000055555587d390 Run`partial apply forwarder for closure #1 (A) -> () in (extension in Async):NIO.EventLoopFuture.flatMap<A>(to: A1.Type, _: (A) throws -> NIO.EventLoopFuture<A1>) -> NIO.EventLoopFuture<A1> at <compiler-generated>) at EventLoopFuture.swift:631:17
    frame #42: 0x0000555555c092c5 Run`partial apply for closure #1 in EventLoopFuture.whenSuccess(_:) at <compiler-generated>:0
    frame #43: 0x0000555555c00090 Run`thunk for @escaping @callee_guaranteed () -> (@owned CallbackList) at <compiler-generated>:0
    frame #44: 0x0000555555c0ec51 Run`thunk for @escaping @callee_guaranteed () -> (@owned CallbackList)partial apply at <compiler-generated>:0
    frame #45: 0x0000555555bffbe3 Run`thunk for @escaping @callee_guaranteed () -> (@out CallbackList) at <compiler-generated>:0
    frame #46: 0x0000555555c0edd1 Run`thunk for @escaping @callee_guaranteed () -> (@out CallbackList)partial apply at <compiler-generated>:0
    frame #47: 0x0000555555c01106 Run`CallbackList._run(self=<unavailable>) at EventLoopFuture.swift:108:32
    frame #48: 0x0000555555c017a4 Run`EventLoopPromise._resolve(value=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:192:37
    frame #49: 0x0000555555c0164c Run`EventLoopPromise.succeed(result=0x00007fffd405aca0 -> 0x00005555563af828 full type metadata for App.EventSlot + 16, self=<unavailable>) at EventLoopFuture.swift:171:9
    frame #50: 0x0000555555c08f21 Run`closure #1 in EventLoopFuture.cascade(v=<unavailable>, promise=<unavailable>) at EventLoopFuture.swift:766:25
    frame #51: 0x0000555555c08f9c Run`partial apply for closure #1 in EventLoopFuture.cascade(promise:) at <compiler-generated>:0
    frame #52: 0x0000555555c06a1d Run`closure #1 in EventLoopFuture._whenCompleteWithValue(callback=0x0000555555c08f80 Run`partial apply forwarder for closure #1 (NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> () in NIO.EventLoopFuture.cascade(promise: NIO.EventLoopPromise<A>) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:613:13
    frame #53: 0x0000555555c0eb95 Run`partial apply for closure #1 in EventLoopFuture._whenCompleteWithValue(_:) at <compiler-generated>:0
    frame #54: 0x0000555555c0464b Run`EventLoopFuture._addCallback(callback=0x0000555555c0eb80 Run`partial apply forwarder for closure #1 () -> NIO.(CallbackList in _1CAEE0056AB83634CE1A29DE57BC300C) in NIO.EventLoopFuture.(_whenCompleteWithValue in _1CAEE0056AB83634CE1A29DE57BC300C)((NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> ()) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:597:16
    frame #55: 0x0000555555c04855 Run`EventLoopFuture._whenComplete(callback=0x0000555555c0eb80 Run`partial apply forwarder for closure #1 () -> NIO.(CallbackList in _1CAEE0056AB83634CE1A29DE57BC300C) in NIO.EventLoopFuture.(_whenCompleteWithValue in _1CAEE0056AB83634CE1A29DE57BC300C)((NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> ()) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:603:13
    frame #56: 0x0000555555c0681f Run`EventLoopFuture._whenCompleteWithValue(callback=0x0000555555c08f80 Run`partial apply forwarder for closure #1 (NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> () in NIO.EventLoopFuture.cascade(promise: NIO.EventLoopPromise<A>) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:612:9
    frame #57: 0x0000555555c04754 Run`EventLoopFuture.cascade(promise=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:761:9
    frame #58: 0x000055555587d284 Run`closure #1 in EventLoopFuture.flatMap<A>(expectation=0x00007fffd405aca0 -> 0x00005555563af828 full type metadata for App.EventSlot + 16, callback=0x00005555559efb30 Run`partial apply forwarder for closure #3 (B) -> NIO.EventLoopFuture<B> in closure #1 (A.Connection) throws -> NIO.EventLoopFuture<B> in (extension in Fluent):Fluent.QueryBuilder< where A == B.Database, B: Fluent.Model>.update(_: B, originalID: Swift.Optional<B.ID>) -> NIO.EventLoopFuture<B> at <compiler-generated>, promise=<unavailable>) at Future+Map.swift:51:24
    frame #59: 0x000055555587d3c9 Run`partial apply for closure #1 in EventLoopFuture.flatMap<A>(to:_:) at <compiler-generated>:0
    frame #60: 0x0000555555c06d1f Run`closure #1 in EventLoopFuture.whenSuccess(self=<unavailable>, callback=0x000055555587d390 Run`partial apply forwarder for closure #1 (A) -> () in (extension in Async):NIO.EventLoopFuture.flatMap<A>(to: A1.Type, _: (A) throws -> NIO.EventLoopFuture<A1>) -> NIO.EventLoopFuture<A1> at <compiler-generated>) at EventLoopFuture.swift:631:17
    frame #61: 0x0000555555c092c5 Run`partial apply for closure #1 in EventLoopFuture.whenSuccess(_:) at <compiler-generated>:0
    frame #62: 0x0000555555c00090 Run`thunk for @escaping @callee_guaranteed () -> (@owned CallbackList) at <compiler-generated>:0
    frame #63: 0x0000555555c0ec51 Run`thunk for @escaping @callee_guaranteed () -> (@owned CallbackList)partial apply at <compiler-generated>:0
    frame #64: 0x0000555555bffbe3 Run`thunk for @escaping @callee_guaranteed () -> (@out CallbackList) at <compiler-generated>:0
    frame #65: 0x0000555555c0edd1 Run`thunk for @escaping @callee_guaranteed () -> (@out CallbackList)partial apply at <compiler-generated>:0
    frame #66: 0x0000555555c01106 Run`CallbackList._run(self=<unavailable>) at EventLoopFuture.swift:108:32
    frame #67: 0x0000555555c017a4 Run`EventLoopPromise._resolve(value=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:192:37
    frame #68: 0x0000555555c0164c Run`EventLoopPromise.succeed(result=0x00007fffd405aca0 -> 0x00005555563af828 full type metadata for App.EventSlot + 16, self=<unavailable>) at EventLoopFuture.swift:171:9
    frame #69: 0x0000555555c08f21 Run`closure #1 in EventLoopFuture.cascade(v=<unavailable>, promise=<unavailable>) at EventLoopFuture.swift:766:25
    frame #70: 0x0000555555c08f9c Run`partial apply for closure #1 in EventLoopFuture.cascade(promise:) at <compiler-generated>:0
    frame #71: 0x0000555555c06a1d Run`closure #1 in EventLoopFuture._whenCompleteWithValue(callback=0x0000555555c08f80 Run`partial apply forwarder for closure #1 (NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> () in NIO.EventLoopFuture.cascade(promise: NIO.EventLoopPromise<A>) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:613:13
    frame #72: 0x0000555555c0eb95 Run`partial apply for closure #1 in EventLoopFuture._whenCompleteWithValue(_:) at <compiler-generated>:0
    frame #73: 0x0000555555c00734 Run`CallbackList._run(self=<unavailable>) at EventLoopFuture.swift:82:27
    frame #74: 0x0000555555c017a4 Run`EventLoopPromise._resolve(value=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:192:37
    frame #75: 0x0000555555c0164c Run`EventLoopPromise.succeed(result=0x00007fffd405aca0 -> 0x00005555563af828 full type metadata for App.EventSlot + 16, self=<unavailable>) at EventLoopFuture.swift:171:9
    frame #76: 0x000055555587cc8b Run`closure #1 in EventLoopFuture.map<A>(expectation=() @ 0x00007fffe94d07c0, callback=0x000055555587e0a0 Run`partial apply forwarder for closure #1 (A) -> A1 in (extension in Async):NIO.EventLoopFuture.transform<A>(to: @autoclosure () -> A1) -> NIO.EventLoopFuture<A1> at <compiler-generated>, promise=<unavailable>) at Future+Map.swift:22:25
    frame #77: 0x000055555587cdd9 Run`partial apply for closure #1 in EventLoopFuture.map<A>(to:_:) at <compiler-generated>:0
    frame #78: 0x0000555555c06d1f Run`closure #1 in EventLoopFuture.whenSuccess(self=<unavailable>, callback=0x000055555587cda0 Run`partial apply forwarder for closure #1 (A) -> () in (extension in Async):NIO.EventLoopFuture.map<A>(to: A1.Type, _: (A) throws -> A1) -> NIO.EventLoopFuture<A1> at <compiler-generated>) at EventLoopFuture.swift:631:17
    frame #79: 0x0000555555c092c5 Run`partial apply for closure #1 in EventLoopFuture.whenSuccess(_:) at <compiler-generated>:0
    frame #80: 0x0000555555c00090 Run`thunk for @escaping @callee_guaranteed () -> (@owned CallbackList) at <compiler-generated>:0
    frame #81: 0x0000555555c0ec51 Run`thunk for @escaping @callee_guaranteed () -> (@owned CallbackList)partial apply at <compiler-generated>:0
    frame #82: 0x0000555555bffbe3 Run`thunk for @escaping @callee_guaranteed () -> (@out CallbackList) at <compiler-generated>:0
    frame #83: 0x0000555555c0edd1 Run`thunk for @escaping @callee_guaranteed () -> (@out CallbackList)partial apply at <compiler-generated>:0
    frame #84: 0x0000555555c01106 Run`CallbackList._run(self=<unavailable>) at EventLoopFuture.swift:108:32
    frame #85: 0x0000555555c017a4 Run`EventLoopPromise._resolve(value=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:192:37
    frame #86: 0x0000555555c0164c Run`EventLoopPromise.succeed(result=() @ 0x00007fffe94d0fa0, self=<unavailable>) at EventLoopFuture.swift:171:9
    frame #87: 0x0000555555c08f21 Run`closure #1 in EventLoopFuture.cascade(v=<unavailable>, promise=<unavailable>) at EventLoopFuture.swift:766:25
    frame #88: 0x0000555555c08f9c Run`partial apply for closure #1 in EventLoopFuture.cascade(promise:) at <compiler-generated>:0
    frame #89: 0x0000555555c06a1d Run`closure #1 in EventLoopFuture._whenCompleteWithValue(callback=0x0000555555c08f80 Run`partial apply forwarder for closure #1 (NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> () in NIO.EventLoopFuture.cascade(promise: NIO.EventLoopPromise<A>) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:613:13
    frame #90: 0x0000555555c0eb95 Run`partial apply for closure #1 in EventLoopFuture._whenCompleteWithValue(_:) at <compiler-generated>:0
    frame #91: 0x0000555555c00734 Run`CallbackList._run(self=<unavailable>) at EventLoopFuture.swift:82:27
    frame #92: 0x0000555555c017a4 Run`EventLoopPromise._resolve(value=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:192:37
    frame #93: 0x0000555555c0164c Run`EventLoopPromise.succeed(result=() @ 0x00007fffe94d1780, self=<unavailable>) at EventLoopFuture.swift:171:9
    frame #94: 0x0000555555c08f21 Run`closure #1 in EventLoopFuture.cascade(v=<unavailable>, promise=<unavailable>) at EventLoopFuture.swift:766:25
    frame #95: 0x0000555555c08f9c Run`partial apply for closure #1 in EventLoopFuture.cascade(promise:) at <compiler-generated>:0
    frame #96: 0x0000555555c06a1d Run`closure #1 in EventLoopFuture._whenCompleteWithValue(callback=0x0000555555c08f80 Run`partial apply forwarder for closure #1 (NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> () in NIO.EventLoopFuture.cascade(promise: NIO.EventLoopPromise<A>) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:613:13
    frame #97: 0x0000555555c0eb95 Run`partial apply for closure #1 in EventLoopFuture._whenCompleteWithValue(_:) at <compiler-generated>:0
    frame #98: 0x0000555555c00090 Run`thunk for @escaping @callee_guaranteed () -> (@owned CallbackList) at <compiler-generated>:0
    frame #99: 0x0000555555c0eab1 Run`thunk for @escaping @callee_guaranteed () -> (@owned CallbackList)partial apply at <compiler-generated>:0
    frame #100: 0x0000555555bffbe3 Run`thunk for @escaping @callee_guaranteed () -> (@out CallbackList) at <compiler-generated>:0
    frame #101: 0x0000555555c0edd1 Run`thunk for @escaping @callee_guaranteed () -> (@out CallbackList)partial apply at <compiler-generated>:0
    frame #102: 0x0000555555c01106 Run`CallbackList._run(self=<unavailable>) at EventLoopFuture.swift:108:32
    frame #103: 0x0000555555c017a4 Run`EventLoopPromise._resolve(value=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:192:37
    frame #104: 0x0000555555c0164c Run`EventLoopPromise.succeed(result=() @ 0x00007fffe94d1fd0, self=<unavailable>) at EventLoopFuture.swift:171:9
    frame #105: 0x0000555555c08f21 Run`closure #1 in EventLoopFuture.cascade(v=<unavailable>, promise=<unavailable>) at EventLoopFuture.swift:766:25
    frame #106: 0x0000555555c08f9c Run`partial apply for closure #1 in EventLoopFuture.cascade(promise:) at <compiler-generated>:0
    frame #107: 0x0000555555c06a1d Run`closure #1 in EventLoopFuture._whenCompleteWithValue(callback=0x0000555555c08f80 Run`partial apply forwarder for closure #1 (NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> () in NIO.EventLoopFuture.cascade(promise: NIO.EventLoopPromise<A>) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:613:13
    frame #108: 0x0000555555c0eb95 Run`partial apply for closure #1 in EventLoopFuture._whenCompleteWithValue(_:) at <compiler-generated>:0
    frame #109: 0x0000555555c00734 Run`CallbackList._run(self=<unavailable>) at EventLoopFuture.swift:82:27
    frame #110: 0x0000555555c017a4 Run`EventLoopPromise._resolve(value=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:192:37
    frame #111: 0x0000555555c0164c Run`EventLoopPromise.succeed(result=() @ 0x00007fffe94d27b0, self=<unavailable>) at EventLoopFuture.swift:171:9
    frame #112: 0x0000555555c08f21 Run`closure #1 in EventLoopFuture.cascade(v=<unavailable>, promise=<unavailable>) at EventLoopFuture.swift:766:25
    frame #113: 0x0000555555c08f9c Run`partial apply for closure #1 in EventLoopFuture.cascade(promise:) at <compiler-generated>:0
    frame #114: 0x0000555555c06a1d Run`closure #1 in EventLoopFuture._whenCompleteWithValue(callback=0x0000555555c08f80 Run`partial apply forwarder for closure #1 (NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> () in NIO.EventLoopFuture.cascade(promise: NIO.EventLoopPromise<A>) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:613:13
    frame #115: 0x0000555555c0eb95 Run`partial apply for closure #1 in EventLoopFuture._whenCompleteWithValue(_:) at <compiler-generated>:0
    frame #116: 0x0000555555c00734 Run`CallbackList._run(self=<unavailable>) at EventLoopFuture.swift:82:27
    frame #117: 0x0000555555c017a4 Run`EventLoopPromise._resolve(value=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:192:37
    frame #118: 0x0000555555c0164c Run`EventLoopPromise.succeed(result=() @ 0x00007fffe94d2f90, self=<unavailable>) at EventLoopFuture.swift:171:9
    frame #119: 0x0000555555c08f21 Run`closure #1 in EventLoopFuture.cascade(v=<unavailable>, promise=<unavailable>) at EventLoopFuture.swift:766:25
    frame #120: 0x0000555555c08f9c Run`partial apply for closure #1 in EventLoopFuture.cascade(promise:) at <compiler-generated>:0
    frame #121: 0x0000555555c06a1d Run`closure #1 in EventLoopFuture._whenCompleteWithValue(callback=0x0000555555c08f80 Run`partial apply forwarder for closure #1 (NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> () in NIO.EventLoopFuture.cascade(promise: NIO.EventLoopPromise<A>) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:613:13
    frame #122: 0x0000555555c0eb95 Run`partial apply for closure #1 in EventLoopFuture._whenCompleteWithValue(_:) at <compiler-generated>:0
    frame #123: 0x0000555555c00090 Run`thunk for @escaping @callee_guaranteed () -> (@owned CallbackList) at <compiler-generated>:0
    frame #124: 0x0000555555c0eab1 Run`thunk for @escaping @callee_guaranteed () -> (@owned CallbackList)partial apply at <compiler-generated>:0
    frame #125: 0x0000555555bffbe3 Run`thunk for @escaping @callee_guaranteed () -> (@out CallbackList) at <compiler-generated>:0
    frame #126: 0x0000555555c0edd1 Run`thunk for @escaping @callee_guaranteed () -> (@out CallbackList)partial apply at <compiler-generated>:0
    frame #127: 0x0000555555c01106 Run`CallbackList._run(self=<unavailable>) at EventLoopFuture.swift:108:32
    frame #128: 0x0000555555c017a4 Run`EventLoopPromise._resolve(value=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:192:37
    frame #129: 0x0000555555c0164c Run`EventLoopPromise.succeed(result=() @ 0x00007fffe94d37e0, self=<unavailable>) at EventLoopFuture.swift:171:9
    frame #130: 0x0000555555c08f21 Run`closure #1 in EventLoopFuture.cascade(v=<unavailable>, promise=<unavailable>) at EventLoopFuture.swift:766:25
    frame #131: 0x0000555555c08f9c Run`partial apply for closure #1 in EventLoopFuture.cascade(promise:) at <compiler-generated>:0
    frame #132: 0x0000555555c06a1d Run`closure #1 in EventLoopFuture._whenCompleteWithValue(callback=0x0000555555c08f80 Run`partial apply forwarder for closure #1 (NIO.(EventLoopFutureValue in _1CAEE0056AB83634CE1A29DE57BC300C)<A>) -> () in NIO.EventLoopFuture.cascade(promise: NIO.EventLoopPromise<A>) -> () at <compiler-generated>, self=<unavailable>) at EventLoopFuture.swift:613:13
    frame #133: 0x0000555555c0eb95 Run`partial apply for closure #1 in EventLoopFuture._whenCompleteWithValue(_:) at <compiler-generated>:0
    frame #134: 0x0000555555c00734 Run`CallbackList._run(self=<unavailable>) at EventLoopFuture.swift:82:27
    frame #135: 0x0000555555c017a4 Run`EventLoopPromise._resolve(value=<unavailable>, self=<unavailable>) at EventLoopFuture.swift:192:37
    frame #136: 0x0000555555c0164c Run`EventLoopPromise.succeed(result=() @ 0x00007fffd404ef50, self=<unavailable>) at EventLoopFuture.swift:171:9
    frame #137: 0x0000555555883fa2 Run`EventLoopPromise<A>.succeed(self=<unavailable>) at Future+Void.swift:4:14
    frame #138: 0x0000555555886f51 Run`QueueHandler.channelRead(ctx=<unavailable>, data=<unavailable>, self=<unavailable>) at QueueHandler.swift:103:33
    frame #139: 0x00005555558881a9 Run`protocol witness for _ChannelInboundHandler.channelRead(ctx:data:) in conformance QueueHandler<A, B> at <compiler-generated>:0
    frame #140: 0x0000555555bcb536 Run`ChannelHandlerContext.invokeChannelRead(data=<unavailable>, self=<unavailable>) at ChannelPipeline.swift:1322:28
    frame #141: 0x0000555555bcff52 Run`ChannelHandlerContext.fireChannelRead(data=<unavailable>, self=<unavailable>) at ChannelPipeline.swift:1135:20
    frame #142: 0x0000555555e09e73 Run`PostgreSQLMessageDecoder.decode(ctx=<unavailable>, buffer=<unavailable>, self=<unavailable>) at PostgreSQLMessageDecoder.swift:87:13
    frame #143: 0x0000555555e0b406 Run`protocol witness for ByteToMessageDecoder.decode(ctx:buffer:) in conformance PostgreSQLMessageDecoder at <compiler-generated>:0
    frame #144: 0x0000555555bdf249 Run`partial apply at <compiler-generated>:0
    frame #145: 0x0000555555bdc0c4 Run`ByteToMessageDecoder.decodeLoop(ctx=<unavailable>, decodeFunc=0x0000555555bdf210 Run`partial apply forwarder with unmangled suffix ".17" at <compiler-generated>, self=0x00007fffd402f050 -> 0x00005555563b8188 full type metadata for PostgreSQL.PostgreSQLMessageDecoder + 16) at Codec.swift:116:30
    frame #146: 0x0000555555bdd56f Run`closure #1 in ByteToMessageDecoder.channelRead(self=0x00007fffd402f050 -> 0x00005555563b8188 full type metadata for PostgreSQL.PostgreSQLMessageDecoder + 16, ctx=<unavailable>) at Codec.swift:146:22
    frame #147: 0x0000555555bdd675 Run`partial apply for closure #1 in ByteToMessageDecoder.channelRead(ctx:data:) at <compiler-generated>:0
    frame #148: 0x0000555555b71a36 Run`thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #149: 0x0000555555bdd7ab Run`partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) at <compiler-generated>:0
    frame #150: 0x0000555555bdb721 Run`ChannelHandlerContext.withThrowingToFireErrorAndClose<A>(body=0x0000555555bdd790 Run`partial apply forwarder for reabstraction thunk helper from @callee_guaranteed () -> (@error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out (), @error @owned Swift.Error) at <compiler-generated>, self=<unavailable>) at Codec.swift:95:24
    frame #151: 0x0000555555bdd036 Run`ByteToMessageDecoder.channelRead(ctx=<unavailable>, data=<unavailable>, self=0x00007fffd402f050 -> 0x00005555563b8188 full type metadata for PostgreSQL.PostgreSQLMessageDecoder + 16) at Codec.swift:145:13
    frame #152: 0x0000555555e0b5e0 Run`protocol witness for _ChannelInboundHandler.channelRead(ctx:data:) in conformance PostgreSQLMessageDecoder at <compiler-generated>:0
    frame #153: 0x0000555555bcb536 Run`ChannelHandlerContext.invokeChannelRead(data=<unavailable>, self=<unavailable>) at ChannelPipeline.swift:1322:28
    frame #154: 0x0000555555bcb5c5 Run`ChannelHandlerContext.invokeChannelRead(data=<unavailable>, self=<unavailable>) at ChannelPipeline.swift:1324:24
    frame #155: 0x0000555555bc4d3c Run`ChannelPipeline.fireChannelRead0(data=<unavailable>, self=<unavailable>) at ChannelPipeline.swift:845:29
    frame #156: 0x0000555555c863d5 Run`SocketChannel.readFromSocket(self=<unavailable>) at SocketChannel.swift:144:30
    frame #157: 0x0000555555b7bd99 Run`BaseSocketChannel.readable0(self=<unavailable>) at BaseSocketChannel.swift:966:30
    frame #158: 0x0000555555b7d54e Run`BaseSocketChannel.readable(self=<unavailable>) at BaseSocketChannel.swift:950:14
    frame #159: 0x0000555555b7ec99 Run`protocol witness for SelectableChannel.readable() in conformance BaseSocketChannel<A> at <compiler-generated>:0
    frame #160: 0x0000555555bf4a75 Run`SelectableEventLoop.handleEvent<A>(ev=<unavailable>, channel=0x00007fffd4099b50 -> 0x00005555563b59f0 full type metadata for NIO.SocketChannel + 16, self=<unavailable>) at EventLoop.swift:637:25
#9

Then with @johannesweiss we tried to investigate it more with lldb like this

break command add

then

p $rdi
cont
DONE

then

cont

and once I'm reproducing the crash output looks like this

Command #2 'cont' continued the target.
(lldb)  p $rdi
(unsigned long) $19 = 140736616211760

(lldb)  cont
Process 3874 resuming

Command #2 'cont' continued the target.
(lldb)  p $rdi
(unsigned long) $20 = 0

(lldb)  cont
Process 3874 resuming

Command #2 'cont' continued the target.
Process 3874 stopped
* thread #9, name = 'NIO-ELT-#0', stop reason = signal SIGSEGV: invalid address (fault address: 0x18)
    frame #0: 0x00007ffff75cfd90 libFoundation.so`CFLocaleGetIdentifier
libFoundation.so`CFLocaleGetIdentifier:
->  0x7ffff75cfd90 <+0>: movq   0x18(%rdi), %rax
    0x7ffff75cfd94 <+4>: retq
    0x7ffff75cfd95:      nopw   %cs:(%rax,%rax)
    0x7ffff75cfd9f:      nop
Target 0: (Run) stopped.
(lldb)

so it seems like we're calling CFLocaleGetIdentifier with NULL CFLocale which is illegal
this happens because I'm calling

Calendar.current.dateComponents([.weekday], from: date).weekday

I'm on Ubuntu 16.04 with Swift 5.0 and locale command prints this

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

but it's not related to this cause with Swift 4.2 it works without crashes
so @johannesweiss filed a bug https://bugs.swift.org/browse/SR-10333