NetService icon indicating copy to clipboard operation
NetService copied to clipboard

SegFault on resolution of service address.

Open Diggory opened this issue 1 year ago • 0 comments

Hello,

I'm attempting to use the package but am finding that it crashes when one tries to resolve the address of a discovered service.

This is with libavahi-compat-libdnssd-dev. Version 0.8-5+deb11u2 on Raspberry Pi OS (Bullseye) and Swift v5.8 or v.5.9

See sample project here: https://github.com/Diggory/NetServiceLinuxTest

Thread 0 “NetServiceLinux” crashed:
 0 NetService.didResolveAddress(host:port:textRecord:) + 252 in NetServiceLinuxTest at /home/pi/Swift/NetServiceLinuxTest/.build/checkouts/NetService/Sources/NetService/NetService.swift:489:23
   487│
   488│   fileprivate func didResolveAddress(host: String, port: UInt16, textRecord: Data?) {
   489│     self.hostName = host
   │            ▲
   490│     self.port = Int(port)
   491│     self.textRecord = textRecord
 1 closure #1 in variable initialization expression of _resolveReply + 983 in NetServiceLinuxTest at /home/pi/Swift/NetServiceLinuxTest/.build/checkouts/NetService/Sources/NetService/NetService.swift:45:13
  43│   let port = UInt16(bigEndian: port)
  44│   let textRecord = txtRecord.map { Data(bytes: $0, count: Int(txtLen)) }
  45│   service.didResolveAddress(
   │       ▲
  46│     host: hosttarget,
  47│     port: port,
 2 0x0000007fb4825af8 <unknown> in libdns_sd.so.1.0.0
 3 0x0000007fb3375a78 <unknown> in libavahi-client.so.3.2.9
 4 0x0000007fb33713d4 <unknown> in libavahi-client.so.3.2.9
 5 0x0000007fb2bc9e74 <unknown> in libdbus-1.so.3.19.17
 6 0x0000007fb3377c50 <unknown> in libavahi-client.so.3.2.9
 7 0x0000007fb3394ebc <unknown> in libavahi-common.so.3.5.4
 8 0x0000007fb4825fa8 <unknown> in libdns_sd.so.1.0.0
 9 NetService.processResult() + 75 in NetServiceLinuxTest at /home/pi/Swift/NetServiceLinuxTest/.build/checkouts/NetService/Sources/NetService/NetService.swift:512:9
   510│
   511│   fileprivate func processResult() {
   512│     DNSServiceProcessResult(serviceRef)
   │     ▲
   513│   }
   514│ }
10 closure #1 in variable initialization expression of _processResult + 375 in NetServiceLinuxTest at /home/pi/Swift/NetServiceLinuxTest/.build/checkouts/NetService/Sources/NetService/NetService.swift:53:13
  51│ private let _processResult: CFSocketCallBack = { (_, _, _, _, info) in
  52│   let service: NetService = Unmanaged.fromOpaque(info!).takeUnretainedValue()
  53│   service.processResult()
   │       ▲
  54│ }
  55│
11 0x0000007fb3ba545c __CFSocketPerformV0 + 1539 in libFoundation.so
12 0x0000007fb3ba27a8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 23 in libFoundation.so
13 0x0000007fb3ba2404 __CFRunLoopDoSources0 + 359 in libFoundation.so
14 0x0000007fb3b9e1f8 __CFRunLoopRun + 671 in libFoundation.so
15 0x0000007fb3b9dcd8 CFRunLoopRunSpecific + 475 in libFoundation.so
16 0x0000007fb3afc2b0 RunLoop.run(mode:before:) + 243 in libFoundation.so
17 NetServiceLinuxTest_main + 323 in NetServiceLinuxTest at /home/pi/Swift/NetServiceLinuxTest/Sources/main.swift:16:33
  14│ let shouldKeepRunning = true
  15│ //   Run forever
  16│ while shouldKeepRunning == true &&
   │                 ▲
  17│         runLoop.run(mode:.default, before: distantFuture) {}
  18│
18 0x0000007fb33cce18 __libc_start_main + 231 in libc-2.31.so
Segmentation fault

Diggory avatar Nov 27 '23 17:11 Diggory