Commit graph

27 commits

Author SHA1 Message Date
Eero Nurkkala
c04bd94037 pulsecore: thread-posix.c: remove unnecessary assignment
pthread_create(&t->id, NULL, internal_thread_func, t) already
assigns the t->id parameter during the thread construction.
There shouldn't be need to redo this again.

If the system is configured with the thread sanitizer, with meson:
'meson -Db_sanitize=thread', it's apparent that the unnecessary
assignment only causes potential trouble:

08:06:11 MAKE_CHECK='1' /home/test/pulse/pulseaudio/build/src/tests/once-test
Running suite(s): Once
0%: Checks: 1, Failures: 0, Errors: 1
../src/tests/once-test.c:119:E:once:once_test:0: (after this point) Early exit with return value 66

WARNING: ThreadSanitizer: data race (pid=102975)
  Read of size 8 at 0x7b0c000012c0 by main thread:
    #0 pa_thread_join ../src/pulsecore/thread-posix.c:143 (libpulsecommon-13.99.so+0x8aca4)
    #1 once_test ../src/tests/once-test.c:105 (once-test+0x2b13)
    #2 srunner_run <null> (once-test+0x58e5)
    #3 __libc_start_main <null> (libc.so.6+0x270b2)

  Previous write of size 8 at 0x7b0c000012c0 by thread T61:
    #0 internal_thread_func ../src/pulsecore/thread-posix.c:76 (libpulsecommon-13.99.so+0x8a715)
    #1 <null> <null> (libtsan.so.0+0x2d1af)

  Location is heap block of size 40 at 0x7b0c000012c0 allocated by main thread:
    #0 calloc <null> (libtsan.so.0+0x305ca)
    #1 pa_xmalloc0 ../src/pulse/xmalloc.c:74 (libpulse.so.0+0x6355b)
    #2 _pa_xnew0_internal ../src/pulse/xmalloc.h:75 (libpulsecommon-13.99.so+0x8a267)
    #3 pa_thread_new ../src/pulsecore/thread-posix.c:92 (libpulsecommon-13.99.so+0x8a828)
    #4 once_test ../src/tests/once-test.c:102 (once-test+0x2a98)
    #5 srunner_run <null> (once-test+0x58e5)
    #6 __libc_start_main <null> (libc.so.6+0x270b2)

  Thread T61 'once' (tid=110679, finished) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 pa_thread_new ../src/pulsecore/thread-posix.c:97 (libpulsecommon-13.99.so+0x8a8aa)
    #2 once_test ../src/tests/once-test.c:102 (once-test+0x2a98)
    #3 srunner_run <null> (once-test+0x58e5)
    #4 __libc_start_main <null> (libc.so.6+0x270b2)

SUMMARY: ThreadSanitizer: data race ../src/pulsecore/thread-posix.c:143 in pa_thread_join

ThreadSanitizer: reported 1 warnings

Fix this warning by removing the unnecessary assignment.

Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
2020-11-23 19:09:31 +00:00
Ondrej Holecek
5effc83479 update FSF addresses to FSF web page
FSF addresses used in PA sources are no longer valid and rpmlint
generates numerous warnings during packaging because of this.
This patch changes all FSF addresses to FSF web page according to
the GPL how-to: https://www.gnu.org/licenses/gpl-howto.en.html

Done automatically by sed-ing through sources.
2015-01-14 22:20:40 +02:00
Stefan Sperling
d8e2b3a78c Fix undefined behaviour in pulseaudio --start.
Don't call pthread_join() to join a thread from a different
process than the thread was created in. Doing so can lead to
undefined behaviour.

On OpenBSD, the symptom was a pulseaudio process with a single
thread waiting forever for other threads to join. Since that
process also held the autospawn lock, starting new pulseaudio
processes with --start kept failing. The problem was analyzed
with help from Philip Guenther.

This patch adds a pa_thread_free_nojoin() function which can
be used to free resources for a thread without a join, as
suggested by Tanu Kaskinen.

See https://bugs.freedesktop.org/show_bug.cgi?id=71738
2013-11-22 17:31:11 +02:00
poljar (Damir Jelić)
d806b19714 Remove pa_bool_t and replace it with bool.
commands used for this (executed from the pulseaudio/src directory):
    find . -regex '\(.*\.[hc]\|.*\.cc\|.*\.m4\)' -not -name 'macro.h' \
        -a -not -name 'reserve.[ch]' -a -not -name 'reserve-monitor.[ch]' \
        -a -not -name 'glib-mainloop.c' -a -not -name 'gkt-test.c' \
        -a -not -name 'glib-mainloop.c' -a -not -name 'gkt-test.c' \
        -a -not -name 'poll-win32.c' -a -not -name 'thread-win32.c' \
        -a -not -name 'dllmain.c' -a -not -name 'gconf-helper.c' \
        -exec sed -i -e 's/\bpa_bool_t\b/bool/g' \
        -e 's/\bTRUE\b/true/g' -e 's/\bFALSE\b/false/g' {} \;

and:
    sed -i -e '181,194!s/\bpa_bool_t\b/bool/' \
        -e '181,194!s/\bTRUE\b/true/' -e \
        '181,194!s/\bFALSE\b/false/' pulsecore/macro.h
2013-07-04 12:25:30 +03:00
Maarten Bosmans
dd9265ac78 Remove unnecessary #includes 2011-06-22 23:12:20 +01:00
Daniel Mack
2411d9accd thread-posix: Use pthread_(get|set)name_np() if available
Newer generations of libpthread have functions to set and get the thread
names. If available, use them.
2011-04-23 18:23:37 +01:00
Lennart Poettering
cdc2769162 thread: name all threads so that the names appear in /proc/$PID/task/$TID/comm 2010-05-07 23:58:59 +02:00
Lennart Poettering
7f7455b1be once: make once related variables volatile 2010-02-09 22:31:30 +00:00
Colin Guthrie
86dee05aec Use LGPL 2.1 on all files previously using LGPL 2 2009-03-03 20:23:02 +00:00
Lennart Poettering
6df029a1b1 make sure we don't crash if pa_thread_join() is called more than once on the same pa_thread object 2008-08-08 22:31:24 +02:00
Lennart Poettering
8ae83d618e get rid of svn $ keywords 2008-06-18 23:23:21 +03:00
Lennart Poettering
a67c21f093 merge 'lennart' branch back into trunk.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1971 fefdeb5f-60dc-0310-8127-8f9354f1896f
2007-10-28 19:13:50 +00:00
Lennart Poettering
1e12e0ee8d Kill spaces on EOL
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1465 fefdeb5f-60dc-0310-8127-8f9354f1896f
2007-05-29 17:24:48 +00:00
Lennart Poettering
6a2dffd78a unfortunately we cannot detect if a foreign thread is still running. Thus sucks. But what can we do? U. Drepper thinks our use case is invalid.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1458 fefdeb5f-60dc-0310-8127-8f9354f1896f
2007-05-27 16:59:34 +00:00
Pierre Ossman
06211b7c8f Add copyright notices to all relevant files. (based on svn log)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1426 fefdeb5f-60dc-0310-8127-8f9354f1896f
2007-02-13 15:35:19 +00:00
Pierre Ossman
521daf6f0a Huge trailing whitespace cleanup. Let's keep the tree pure from here on,
mmmkay?


git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1418 fefdeb5f-60dc-0310-8127-8f9354f1896f
2007-01-04 13:43:45 +00:00
Lennart Poettering
6d532029ea update for newer APIs: replace direct usage of libatomic_ops by usage of our own atomic.h; remove pa_once implementation; always use our pa_once implementation instead of the POSIX version
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1386 fefdeb5f-60dc-0310-8127-8f9354f1896f
2006-09-09 22:59:17 +00:00
Lennart Poettering
6bbfb43f2a add accessor functions for the userdata attached to a pa_thread object
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1371 fefdeb5f-60dc-0310-8127-8f9354f1896f
2006-09-04 22:15:15 +00:00
Lennart Poettering
3be920d9ae fix pa_thread_is_running() for foreign threads; fix a memory leak for foreign threads
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1370 fefdeb5f-60dc-0310-8127-8f9354f1896f
2006-09-04 22:04:33 +00:00
Lennart Poettering
8e7c2a3b0c make pa_thread_self() return a sensible pointer on foreign threads
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1368 fefdeb5f-60dc-0310-8127-8f9354f1896f
2006-09-04 21:28:34 +00:00
Pierre Ossman
647ef180c3 Fix call to pa_mutex_new().
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1358 fefdeb5f-60dc-0310-8127-8f9354f1896f
2006-09-01 19:06:44 +00:00
Pierre Ossman
f84c65ed86 Add pthread_once() equivalent support.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1357 fefdeb5f-60dc-0310-8127-8f9354f1896f
2006-09-01 18:39:55 +00:00
Pierre Ossman
6e9706bcbc Also wrap yield functionality so that it can be platform independent.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1353 fefdeb5f-60dc-0310-8127-8f9354f1896f
2006-08-31 16:13:07 +00:00
Lennart Poettering
aee4a3738e define AO_REQUIRE_CAS in the Makefile instead of each source file, effectively reversing r1348
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1351 fefdeb5f-60dc-0310-8127-8f9354f1896f
2006-08-31 15:20:43 +00:00
Lennart Poettering
2f6cc4f8fa fix handling of "running" variable
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1349 fefdeb5f-60dc-0310-8127-8f9354f1896f
2006-08-30 17:12:35 +00:00
Pierre Ossman
ad0535beef Add AO_REQUIRE_CAS as we do.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1348 fefdeb5f-60dc-0310-8127-8f9354f1896f
2006-08-30 17:01:10 +00:00
Lennart Poettering
b2c341f935 add a threading primitive API
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1344 fefdeb5f-60dc-0310-8127-8f9354f1896f
2006-08-29 19:51:14 +00:00