OpenWebRTC iOS random crash gstglcontext
Asked Answered
V

2

8

I am working on a WebRTC project. I chose OpenWebRTC to implement in my project.

I have made it to work for both web and iOS. I developed a signaling server in asp.net MVC and used coTurn server as a turn server.

Everything is working fine except for one issue.

The iOS app crashes randomly with the exception

EXC_BAD_ACCESS exception:(gstglcontext(14):EXC_BAD_ACCESS (code=1,address=0x30))

The exception is thrown from somewhere within the SDK. I have been trying for days now to find a solution, but have not succeeded so far.

Has anyone else faced a similar problem?

Following is the stack trace from the device logs of the crash

Incident Identifier: FA4FC9DB-B4CA-497E-9A25-639A4F743BC8
CrashReporter Key:   ff7120b6353817347fd122932620c25469ace55e
Hardware Model:      iPad4,5
Process:             NativeDemo [983]
Path:                /private/var/containers/Bundle/Application/13129A20-974B-405C-AB44-B5F8526AF362/NativeDemo.app/NativeDemo
Identifier:          com.ericsson.research.owr.NativeDemo
Version:             1 (1.0)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.ericsson.research.owr.NativeDemo [1284]


Date/Time:           2017-03-22 04:52:45.7874 -0700
Launch Time:         2017-03-22 04:26:17.7434 -0700
OS Version:          iPhone OS 10.2.1 (14D27)
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000030
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
Triggered by Thread:  9

Filtered syslog:
None found

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x000000018d3a1188 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x000000018d3a0ff8 mach_msg + 72
2   CoreFoundation                  0x000000018e39e5d0 __CFRunLoopServiceMachPort + 192
3   CoreFoundation                  0x000000018e39c1ec __CFRunLoopRun + 1132
4   CoreFoundation                  0x000000018e2ca2b8 CFRunLoopRunSpecific + 444
5   GraphicsServices                0x000000018fd7e198 GSEventRunModal + 180
6   UIKit                           0x000000019430a7fc -[UIApplication _run] + 684
7   UIKit                           0x0000000194305534 UIApplicationMain + 208
8   NativeDemo                      0x0000000100050e90 0x100040000 + 69264
9   libdyld.dylib                   0x000000018d2ad5b8 start + 4

Thread 1 name:  owr_main_loop
Thread 1:
0   libsystem_kernel.dylib          0x000000018d3a56e4 poll + 8
1   NativeDemo                      0x000000010031d8c0 0x100040000 + 3004608
2   NativeDemo                      0x000000010031dc18 0x100040000 + 3005464
3   NativeDemo                      0x000000010059794c 0x100040000 + 5601612
4   NativeDemo                      0x0000000100597a88 0x100040000 + 5601928
5   NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
6   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
7   libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
8   libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 2 name:  AVAudioSession Notify Thread
Thread 2:
0   libsystem_kernel.dylib          0x000000018d3a1188 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x000000018d3a0ff8 mach_msg + 72
2   CoreFoundation                  0x000000018e39e5d0 __CFRunLoopServiceMachPort + 192
3   CoreFoundation                  0x000000018e39c1ec __CFRunLoopRun + 1132
4   CoreFoundation                  0x000000018e2ca2b8 CFRunLoopRunSpecific + 444
5   AVFAudio                        0x00000001a7867d24 GenericRunLoopThread::Entry(void*) + 164
6   AVFAudio                        0x00000001a788dd9c CAPThread::Entry(CAPThread*) + 84
7   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
8   libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
9   libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 3 name:  com.apple.uikit.eventfetch-thread
Thread 3:
0   libsystem_kernel.dylib          0x000000018d3a1188 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x000000018d3a0ff8 mach_msg + 72
2   CoreFoundation                  0x000000018e39e5d0 __CFRunLoopServiceMachPort + 192
3   CoreFoundation                  0x000000018e39c1ec __CFRunLoopRun + 1132
4   CoreFoundation                  0x000000018e2ca2b8 CFRunLoopRunSpecific + 444
5   Foundation                      0x000000018ee0726c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 304
6   Foundation                      0x000000018ee27dd0 -[NSRunLoop(NSRunLoop) runUntilDate:] + 96
7   UIKit                           0x0000000194c7ec38 -[UIEventFetcher threadMain] + 136
8   Foundation                      0x000000018ef04e68 __NSThread__start__ + 1024
9   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
10  libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
11  libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 4 name:  com.apple.NSURLConnectionLoader
Thread 4:
0   libsystem_kernel.dylib          0x000000018d3a1188 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x000000018d3a0ff8 mach_msg + 72
2   CoreFoundation                  0x000000018e39e5d0 __CFRunLoopServiceMachPort + 192
3   CoreFoundation                  0x000000018e39c1ec __CFRunLoopRun + 1132
4   CoreFoundation                  0x000000018e2ca2b8 CFRunLoopRunSpecific + 444
5   CFNetwork                       0x000000018eacfa70 +[NSURLConnection(Loader) _resourceLoadLoop:] + 336
6   Foundation                      0x000000018ef04e68 __NSThread__start__ + 1024
7   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
8   libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
9   libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 5 name:  gmain
Thread 5:
0   libsystem_kernel.dylib          0x000000018d3a56e4 poll + 8
1   NativeDemo                      0x000000010031d8c0 0x100040000 + 3004608
2   NativeDemo                      0x000000010031d994 0x100040000 + 3004820
3   NativeDemo                      0x000000010031ecec 0x100040000 + 3009772
4   NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
5   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
6   libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
7   libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 6 name:  video-source:src
Thread 6:
0   libsystem_kernel.dylib          0x000000018d3bee1c __psynch_cvwait + 8
1   libsystem_pthread.dylib         0x000000018d4849f4 _pthread_cond_wait + 692
2   Foundation                      0x000000018ee11f28 -[NSCondition waitUntilDate:] + 340
3   Foundation                      0x000000018ee0ef24 -[NSConditionLock lockWhenCondition:beforeDate:] + 256
4   NativeDemo                      0x0000000100070894 0x100040000 + 198804
5   NativeDemo                      0x0000000100071b44 0x100040000 + 203588
6   NativeDemo                      0x000000010040ce74 0x100040000 + 3985012
7   NativeDemo                      0x000000010040c678 0x100040000 + 3982968
8   NativeDemo                      0x00000001004886a8 0x100040000 + 4490920
9   NativeDemo                      0x0000000100303e24 0x100040000 + 2899492
10  NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
11  libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
12  libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
13  libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 7 name:  sink-queue-0:src
Thread 7:
0   libsystem_kernel.dylib          0x000000018d3bee1c __psynch_cvwait + 8
1   libsystem_pthread.dylib         0x000000018d4849c0 _pthread_cond_wait + 640
2   NativeDemo                      0x000000010036a1d0 0x100040000 + 3318224
3   NativeDemo                      0x0000000100099c40 0x100040000 + 367680
4   NativeDemo                      0x00000001004886a8 0x100040000 + 4490920
5   NativeDemo                      0x0000000100303e24 0x100040000 + 2899492
6   NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
7   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
8   libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
9   libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 8 name:  gstglnavigation
Thread 8:
0   libsystem_kernel.dylib          0x000000018d3a56e4 poll + 8
1   NativeDemo                      0x000000010031d8c0 0x100040000 + 3004608
2   NativeDemo                      0x000000010031dc18 0x100040000 + 3005464
3   NativeDemo                      0x000000010043ba28 0x100040000 + 4176424
4   NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
5   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
6   libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
7   libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 9 name:  gstglcontext
Thread 9 Crashed:
0   IOAccelerator                   0x000000019097ecbc IOAccelResourceGetResidentDataSize + 0
1   AGXGLDriver                     0x00000001a2901390 0x1a289a000 + 422800
2   AGXGLDriver                     0x00000001a28c1354 0x1a289a000 + 160596
3   AGXGLDriver                     0x00000001a28c14bc 0x1a289a000 + 160956
4   AGXGLDriver                     0x00000001a28bee38 0x1a289a000 + 151096
5   GLEngine                        0x00000001a303b81c glClear_Exec + 432
6   NativeDemo                      0x00000001000d3340 0x100040000 + 602944
7   NativeDemo                      0x000000010043f8a8 0x100040000 + 4192424
8   NativeDemo                      0x000000010043ccb8 0x100040000 + 4181176
9   NativeDemo                      0x000000010043ccf8 0x100040000 + 4181240
10  NativeDemo                      0x000000010031d5e4 0x100040000 + 3003876
11  NativeDemo                      0x000000010031d924 0x100040000 + 3004708
12  NativeDemo                      0x000000010031dc18 0x100040000 + 3005464
13  NativeDemo                      0x0000000100437f48 0x100040000 + 4161352
14  NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
15  libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
16  libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
17  libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 10 name:  source-output-queue-0:src
Thread 10:
0   libsystem_kernel.dylib          0x000000018d3bee1c __psynch_cvwait + 8
1   libsystem_pthread.dylib         0x000000018d4849c0 _pthread_cond_wait + 640
2   NativeDemo                      0x000000010036a1d0 0x100040000 + 3318224
3   NativeDemo                      0x000000010043ca84 0x100040000 + 4180612
4   NativeDemo                      0x000000010043bde4 0x100040000 + 4177380
5   NativeDemo                      0x00000001000d417c 0x100040000 + 606588
6   NativeDemo                      0x00000001000d2540 0x100040000 + 599360
7   NativeDemo                      0x0000000100403f48 0x100040000 + 3948360
8   NativeDemo                      0x0000000100407524 0x100040000 + 3962148
9   NativeDemo                      0x0000000100472894 0x100040000 + 4401300
10  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
11  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
12  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
13  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
14  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
15  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
16  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
17  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
18  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
19  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
20  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
21  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
22  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
23  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
24  NativeDemo                      0x000000010049b000 0x100040000 + 4567040
25  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
26  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
27  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
28  NativeDemo                      0x000000010049b000 0x100040000 + 4567040
29  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
30  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
31  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
32  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
33  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
34  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
35  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
36  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
37  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
38  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
39  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
40  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
41  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
42  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
43  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
44  NativeDemo                      0x000000010049b000 0x100040000 + 4567040
45  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
46  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
47  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
48  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
49  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
50  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
51  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
52  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
53  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
54  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
55  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
56  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
57  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
58  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
59  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
60  NativeDemo                      0x000000010049b000 0x100040000 + 4567040
61  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
62  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
63  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
64  NativeDemo                      0x000000010049b000 0x100040000 + 4567040
65  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
66  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
67  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
68  NativeDemo                      0x000000010009a014 0x100040000 + 368660
69  NativeDemo                      0x00000001004886a8 0x100040000 + 4490920
70  NativeDemo                      0x0000000100303e24 0x100040000 + 2899492
71  NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
72  libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
73  libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
74  libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

I further tracked down the issue.

The exception is thrown on the following line in gstglimagesink.c in the function 'gst_glimage_sink_on_draw'

gl->Clear (GL_COLOR_BUFFER_BIT);
Vassalage answered 22/3, 2017 at 20:29 Comment(0)
Q
5

Update the gstreamer library to version 1.10.4. The newer version of gstreamer has fixed this bug. To update modify the script 'update-gst.sh' as below master_commit=git ls-remote git://anongit.freedesktop.org/git/gstreamer/$i | grep "1.10.4$" | awk '{print $1}'

Then run the script, after that do a clean build for os x first and then iOS.

Quadrennial answered 3/4, 2017 at 5:33 Comment(0)
G
3
gl->Clear (GL_COLOR_BUFFER_BIT);

At that line gl is a virtual conversion table of type GstGLFuncs. GstGLFuncs is a member of type struct GstGLContext which contains user's data.

So clearly, you don't have the user's data which you are trying to access. You are having a Dangling pointer. This could be because

  1. The pointer(in your case GstGLContext) used to point to memory that was ok, but its chunk was deallocated.
  2. The pointer is corrupt.

The line of code that your app crashes on is not the root cause of the problem. The problem in #1 is whatever line of code caused the premature deallocation, and the problem in #2 is whatever line of code corrupted the pointer.

Gundry answered 29/3, 2017 at 11:4 Comment(3)
Can I check in code if the pointer is dangling or the memory it is pointing to has been released? something like if (*gl == null) { return; }Vassalage
Actually that depends, on how you are using the library. If you are adding the code directly to the Xcode and compiling, then simply add an exception breakpoint and try to regenerate that crash. And it will show you some stacktrace. You can also add code there as you have wanted. But simply escaping the exception by adding something like (*gl == null) { return; } won't give you a root cause for the exception.Gundry
That's the problem, I'm using a static library. I cannot debug the code. But I may have solved it someother way. Running some tests atm. I'll post the solution as soon as I'm sureVassalage

© 2022 - 2024 — McMap. All rights reserved.