Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#1837 closed defect (fixed)

Fix dispatch queue problem in iOS capture device (crash in enc_clock_cb)

Reported by: ming Owned by: ming
Priority: normal Milestone: release-2.4
Component: pjmedia-videodev Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported: no

Description (last modified by ming)

There may be some compatibility problems between dispatch queue and PJLIB functions. In particular, according to the documentation):

The following interfaces MUST NOT be called by blocks submitted to a dispatch queue:
           •   pthread_cancel():
           •   pthread_detach()
           •   pthread_join()
           •   pthread_kill()
           •   pthread_exit()

While the result of pthread_self() may change between invocations of blocks, the value
will not change during the execution of any single block. Because the underlying
thread may change beteween block invocations on a single queue, using per-thread
data as an out-of-band return value is error prone. In other words, the result of
calling pthread_setspecific() and pthread_getspecific() is well defined within
a single block, but not across multiple blocks.

In iOS capture device, calling pj_thread_register() (which relies on pthread_get/setspecific()) inside a dispatch queue may cause crash such as:

#0	0x00056c64 in tee_put_frame at pjmedia/pjmedia/vid_tee.c:360
#1	0x0005427c in enc_clock_cb at pjmedia/src/pjmedia/vid_port.c:1054
#2	0x0003ad7e in clock_thread at pjmedia/src/pjmedia/clock_thread.c:378
#3	0x0002667e in thread_main at pjlib/src/pj/os_core_unix.c:541

Change History (4)

comment:1 Changed 10 years ago by ming

  • Resolution set to fixed
  • Status changed from new to closed

In 5051:

Fixed #1837: Fix premature dispatch queue release in iOS capture device

Also add more logs, error checking, and modify the auto release of video output delegate

comment:2 Changed 10 years ago by ming

  • Description modified (diff)
  • Summary changed from Fix premature dispatch queue release in iOS capture device to Fix dispatch queue problem in iOS capture device (crash in enc_clock_cb)

comment:3 Changed 10 years ago by ming

In 5054:

Re #1837: Fix dispatch queue problem in iOS capture device (crash in enc_clock_cb)

comment:4 Changed 10 years ago by ming

  • Description modified (diff)
Note: See TracTickets for help on using tickets.