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

Telephone crashes with "Use DNS SRV" #669

Open
gsbabil opened this issue Mar 6, 2022 · 7 comments
Open

Telephone crashes with "Use DNS SRV" #669

gsbabil opened this issue Mar 6, 2022 · 7 comments

Comments

@gsbabil
Copy link

gsbabil commented Mar 6, 2022

Hi @eofster,

📌 I'm trying to build the latest d13b7d1 commit for x64_64 but am running into the following memory access violation inside memmove() (originating from PJSIP/PJSUA):

libsystem_platform.dylib`_platform_memmove$VARIANT$Haswell:
    0x7ff805a161a0 <+0>:   pushq  %rbp
    0x7ff805a161a1 <+1>:   movq   %rsp, %rbp
    0x7ff805a161a4 <+4>:   movq   %rdi, %r11
    0x7ff805a161a7 <+7>:   subq   %rsi, %r11
    0x7ff805a161aa <+10>:  movq   %rdi, %rax
    0x7ff805a161ad <+13>:  cmpq   %rdx, %r11
    0x7ff805a161b0 <+16>:  jb     0x7ff805a161cd            ; <+45>
    0x7ff805a161b2 <+18>:  cmpq   $0x60, %rdx
    0x7ff805a161b6 <+22>:  jbe    0x7ff805a161e7            ; <+71>
    0x7ff805a161b8 <+24>:  cmpq   $0x4000, %rdx             ; imm = 0x4000 
    0x7ff805a161bf <+31>:  jb     0x7ff805a16290            ; <+240>
    0x7ff805a161c5 <+37>:  movq   %rdx, %rcx
    0x7ff805a161c8 <+40>:  cld    
->  0x7ff805a161c9 <+41>:  rep    movsb	(%rsi), %es:(%rdi)
    0x7ff805a161cb <+43>:  popq   %rbp
    0x7ff805a161cc <+44>:  retq   
    0x7ff805a161cd <+45>:  cmpq   %rdi, %rsi
Crashed Thread:        12

Exception Type:        EXC_BAD_ACCESS (SIGBUS)
Exception Codes:       KERN_PROTECTION_FAILURE at 0x000070000eb47000
Exception Codes:       0x0000000000000002, 0x000070000eb47000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 10 Bus error: 10
Terminating Process:   exc handler [70079]

VM Region Info: 0x70000eb47000 is in 0x70000eb47000-0x70000eb48000;  bytes after start: 0  bytes before end: 4095
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      Stack                    70000eac5000-70000eb47000 [  520K] rw-/rwx SM=PRV  thread 12
--->  STACK GUARD              70000eb47000-70000eb48000 [    4K] ---/rwx SM=NUL  ... for thread 3
      Stack                    70000eb48000-70000ebca000 [  520K] rw-/rwx SM=PRV  thread 3

📌 The stack trace for the given thread (Treat 12 in this case) looks like the following:

Thread 12 Crashed:
0   libsystem_platform.dylib      	    0x7ff805a161c9 _platform_memmove$VARIANT$Haswell + 41
1   Telephone                     	       0x10799528a stateless_send_resolver_callback + 102
2   Telephone                     	       0x1079969f5 srv_resolver_cb + 401
3   Telephone                     	       0x1079f5185 dns_callback + 2039
4   Telephone                     	       0x1079f25ef on_read_complete + 982
5   Telephone                     	       0x107a22a46 ioqueue_dispatch_read_event + 530
6   Telephone                     	       0x107a23f7b pj_ioqueue_poll + 778
7   Telephone                     	       0x107993586 pjsip_endpt_handle_events2 + 133
8   Telephone                     	       0x1079620f2 pjsua_handle_events + 72
9   Telephone                     	       0x1079619cd worker_thread + 32
10  Telephone                     	       0x107a24cf3 thread_main + 59
11  libsystem_pthread.dylib       	    0x7ff805a034f4 _pthread_start + 125
12  libsystem_pthread.dylib       	    0x7ff8059ff00f thread_start + 15

📌 Following is my build system configuration:

- ProductName    :  macOS (Monterey)
- ProductVersion :  12.2.1
- BuildVersion   :  21D62
- XcodeVersion   :  13.2.1 (13C100)

📌 I have made the necessary adjustments to the Telephone.xcodeproj, compiled Opus, LibreSSL and PJSIP libraries for x86_64, and everything builds without issues, but when I run the freshly built Telephone.app, it runs into the access violation error mentioned above.

📌 I have also tried building with the latest Xcode_13.3_beta_3, but still got the same error. Thanks.

🟡 Would you be able to share some hints on what might be going on and how to prevent the crash? Thanks a lot!

@gsbabil
Copy link
Author

gsbabil commented Mar 6, 2022

Hi @eofster,

🔴 I think I have been able to reliably reproduce the crash within the Network > STUN settings with DNS SRV enabled.

  • If I keep "Use DNS SRV" ticked on, I hit the crash above each time.
  • Keeping "Use DNS SRV" ticked off, prevents the crash. Thanks.

Screen Shot 2022-03-07 at 2 46 05 am

@gsbabil gsbabil changed the title Telephone crashes on Intel Mac built with XCode 13 Telephone crashes with "Use DNS SRV" Mar 6, 2022
@olku
Copy link

olku commented Mar 7, 2022

Afaik stun.freeswitch.org has no SRV records set. So while Telephone should probably not crash over that you should not enable 'Use DNS SRV' for a domain that doesn't support it.

@gsbabil
Copy link
Author

gsbabil commented Mar 7, 2022

Hi @olku,

Afaik stun.freeswitch.org has no SRV records set.

Thanks. Yes, I also thought so.

The app crashes similarly with other STUN servers like stun.l.google.com:19302, where SRV records are unavailable.

So while Telephone should probably not crash over that

Yes again -- this is the main problem. It would be okay if the SIP connection or calls failed, but the unexpected crash is the main issue.

Also, it's not obvious how to recover from the crash, i.e. once you've ticked the "Use DNS SRV" option by mistake, you can't easily disable it. The app will crash every time you restart before you get a chance to disable this option. See my comments here to recover from "wrong data" (issue #668).

Thank you.

@eofster
Copy link
Member

eofster commented Mar 9, 2022

Are you building on Intel? Since I moved to Apple Silicon, I updated the building instructions for building a universal binary on Apple Silicon and kind of don't support building on Intel any more, only running on Intel.

What might work is to use the older building instructions from the Readme. The version before it's been updated for making a universal binary from an ARM Mac.

@eofster
Copy link
Member

eofster commented Mar 9, 2022

To recover from the crash, you can change the app settings via the macOS defaults utility by deleting the STUN server setting:

defaults delete com.tlphn.Telephone STUNServerHost

@gsbabil
Copy link
Author

gsbabil commented Mar 10, 2022

Hi @eofster,

Are you building on Intel?

Yes, I'm building on Intel.

What might work is to use the older building instructions from the Readme.

To confirm, I have added necessary patches to build d13b7d1 on Intel. All functionalities work as expected, except the "Use DNS SRV" crash mentioned above.

Is this something (the crash) you are able to reproduce with your universal binary build? I don't have access to an "Apple Silicon" machine to test it. Thanks.

@eofster
Copy link
Member

eofster commented Mar 15, 2022

That's the thing: I can't reproduce it with universal library on Apple Silicon. Closer to the release, I will also test how the universal library built on Apple Silicon works on Intel. But I won't be going back and testing the builds made on Intel.

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

3 participants