Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault #31

Closed
robreuss opened this issue Jan 7, 2019 · 4 comments
Closed

Segmentation fault #31

robreuss opened this issue Jan 7, 2019 · 4 comments

Comments

@robreuss
Copy link

robreuss commented Jan 7, 2019

I'm getting a seg fault and it's occurring in difficult-to-track ways, suggestive a background process getting into trouble.

Sometimes I get all the way through my browsing and connection process, and exchange data over TCP, but then the seg fault occurs. Other times it seems to occur around the time I call stopBrowsing. Another time, it occurred right after the browser found the same service twice and started to resolve.

My guess is that the last case where the same service was found twice may be the best clue.

@Bouke
Copy link
Owner

Bouke commented Jan 8, 2019

There's no method called stopBrowsing. Can you share a short test program showing how you're using the library? Does the problem also appear when using the debug utility dns-sd?

Below is the output when browsing for services with >1 replies:

macOS:

$ swift run dns-sd -B _airport._tcp
warning: PackageDescription API v3 is deprecated and will be removed in the future; used by package(s): Cdns_sd
Compile Swift Module 'NetService' (6 sources)
Compile Swift Module 'dns_sd' (3 sources)
Browsing for _airport._tcp
DATE: ---Tuesday, 8 January 2019---
19:11:02.002  ...STARTING...
Timestamp     A/R    Flags  if Domain               Service Type         Instance Name
19:11:03.003  Add        ?   ? local.               _airport._tcp.       Bouke's AirPort Express
19:11:03.003  Add        ?   ? local.               _airport._tcp.       Bouke's Time Capsule
^C
$

Raspbian Stretch:

$ swift run dns-sd -B _airport._tcp
Compile Swift Module 'NetService' (6 sources)
Compile Swift Module 'dns_sd' (3 sources)
Linking ./.build/armv7-unknown-linux-gnueabihf/debug/dns-sd
Browsing for _airport._tcp
DATE: ---Tuesday, January 8, 2019---
18:16:40.040  ...STARTING...
Timestamp     A/R    Flags  if Domain               Service Type         Instance Name
*** WARNING *** The program 'dns-sd' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=dns-sd>
18:16:40.040  Add        ?   ? local.               _airport._tcp.       Bouke's AirPort Express
18:16:40.040  Add        ?   ? local.               _airport._tcp.       Bouke's Time Capsule
18:16:40.040  Add        ?   ? local.               _airport._tcp.       Bouke's AirPort Express
18:16:40.040  Add        ?   ? local.               _airport._tcp.       Bouke's Time Capsule
^C
$

@robreuss
Copy link
Author

robreuss commented Jan 8, 2019

Whoops - "stopBrowsing()" is my pass though method for it. I intended to write the method "stop(").

Here is the output from dns-sd on Ubuntu Mate seeing a service on a server instance running in the simulator:

swift run dns-sd -B _robot1._tcp in domain local.
Browsing for _robot1._tcp
DATE: ---Tuesday, January 8, 2019---
18:44:35.035  ...STARTING...
Timestamp     A/R    Flags  if Domain               Service Type         Instance Name
*** WARNING *** The program 'dns-sd' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=dns-sd>
18:45:33.033  Add        ?   ? local.               _robot1._tcp.        iPad Air
18:45:33.033  Add        ?   ? local.               _robot1._tcp.        iPad Air

Should there be more than one reply? Should I be guarding against a second delegate call causing trouble? Let me put such a guard in place and see if it addresses the issue, and otherwise will produce a simplified Linux-based browsing project I can share, and see if I can reproduce the issue in that context.

Thank you.

@robreuss
Copy link
Author

robreuss commented Jan 8, 2019

It was indeed the fact that the same service, search for using searchForServices, returned more than one instance of the service that was messing things up on my end. I would end up resolving the same service at the same time, something that was not an issue with iOS. Interesting that dns-sd would return the same service twice and only twice.

@robreuss robreuss closed this as completed Jan 8, 2019
@Bouke
Copy link
Owner

Bouke commented Jan 13, 2019

I don't know why Avahi resolves the service twice. Maybe once over IPv4 and once over IPv6, and doesn't include logic to deduplicate. This library just passes along what it receives from the resolver; so no duplication will be done there either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants