[FFmpeg-cvslog] pthreads: fix segfault due to the thread beimg killed before it has been allocated

Michael Niedermayer michaelni at gmx.at
Sun Nov 27 06:43:08 CET 2011


On Sun, Nov 27, 2011 at 01:28:29PM +0800, avcoder wrote:
> On Sun, Nov 27, 2011 at 1:12 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Sun, Nov 27, 2011 at 11:56:58AM +0800, avcoder wrote:
> >> Hi, this commit breaks MinGW because 'p->thread' is defined as a struct.
> >
> > oops
> > hopefully fixed
> >
> 
> Your fix is not elegant, the following  hack would be better in my own view:
> 
>         if (*(intptr_t *)&p->thread)
>             pthread_join(p->thread, NULL);

it might work on mingw, but it will fail on other platforms where its
not a pointer. You dont even know that pthread_t has the same length
as a intptr_t nor if 0 is a invalid value. As a long int it surely
can start counting at 0

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-cvslog/attachments/20111127/1d58f1a0/attachment.asc>


More information about the ffmpeg-cvslog mailing list