Question about stream.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 04:17 PM 1/27/2008, Benny Prijono wrote:
>On 1/25/08, Michael Broughton <Michael_Broughton at advanis.ca> wrote:
> > Hello,
> >
> > I am looking at two functions in stream.c: pjmedia_stream_destroy and
> > on_rx_rtp. I am trying to figure out if the following scenario is possible:
> >
> > 1. Thread A calls pjmedia_stream_destroy, which locks stream->jb_mutex.
> >
> > 2. Thread B calls on_rx_rtp, which tries to lock stream->jb_mutex but
> > cannot right away because thread A already holds the lock.
> >
> > 3. Thread A goes about it's work and then free's stream->jb_mutex.
> >
> > 4. Thread B, still trying to lock stream->jb_mutex, segfaults because
> > thread A deallocated stream->jb_mutex and zeroed out the pointer.
> >
> >
> > I have been trying to follow the code and it almost looks like this is
> > possible. Can anyone confirm or disprove this?
> >
>
>Hi Michael,
>
>I've got to say that the scenario looks valid, rather unfortunately. I
>haven't had idea on how to solve it though.

Ok got an idea here.  It has to do with lock_count which associated 
with the lock.

enter_lock():
increments lock count
tries to get the OS lock.

leave_lock():
decrements lock count
releases the OS lock.
if lock_count==0 and marked for deletion // was intended to be 
deleted elsewhere do it now.
     delete lock.

destory_lock():
if lock_count==0 // we can delete now
         remove lock from memory
           set pointer to zero.
else
         mark lock for deletion. // we can delete somewhere else.


>cheers,
>  -benny
>
>
>
> > Thanks,
> >
> > --
> > Michael Broughton, Advanis
> >
> > Unintended Recipient & Unauthorized Use of E-Mail:
> > This message and attachments may contain confidential or privileged
> > information that is intended only for the named recipient of this
> > e-mail. Any unauthorized use or distribution is not permitted. If you
> > have received this e-mail in error, deleting the e-mail and notifying
> > the sender would be appreciated. Thank you.
> >
> >
> > _______________________________________________
> > Visit our blog: http://blog.pjsip.org
> >
> > pjsip mailing list
> > pjsip at lists.pjsip.org
> > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
> >
>
>_______________________________________________
>Visit our blog: http://blog.pjsip.org
>
>pjsip mailing list
>pjsip at lists.pjsip.org
>http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>
>
>--
>No virus found in this incoming message.
>Checked by AVG Free Edition.
>Version: 7.5.516 / Virus Database: 269.19.12/1245 - Release Date: 
>1/26/2008 3:45 PM




[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux