[Mesa-dev] [PATCH 1/4] gallium/u_queue: fix random crashes when the app calls exit()

Michel Dänzer michel at daenzer.net
Thu Feb 23 06:49:16 UTC 2017


On 23/02/17 03:44 PM, Michel Dänzer wrote:
> On 22/02/17 06:05 AM, Marek Olšák wrote:
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> This fixes:
>>     vdpauinfo: ../lib/CodeGen/TargetPassConfig.cpp:579: virtual void
>>     llvm::TargetPassConfig::addMachinePasses(): Assertion `TPI && IPI &&
>>     "Pass ID not registered!"' failed.
>>
>> v2: use list_head, switch the call order in destroy
>>
>> Cc: 13.0 17.0 <mesa-stable at lists.freedesktop.org>
> 
> Hold the press.
> 
> Unfortunately, this broke the piglit tests
> 
> glx at glx_ext_import_context@import context, multi process
> glx at glx_ext_import_context@make current, single process
> 
> so this appears unsafe for apps which call fork().

Forgot to include the backtrace, see below. Note that one has to do

 set follow-fork-mode child

at the gdb prompt before reproducing the problem.


Thread 2.1 "glx-make-curren" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7f85780 (LWP 3219)]
0x00007ffff2ccc5c9 in pthread_join (threadid=140737146943232, thread_return=thread_return at entry=0x7fffffffe518) at pthread_join.c:45
45	pthread_join.c: No such file or directory.
(gdb) bt
#0  0x00007ffff2ccc5c9 in pthread_join (threadid=140737146943232, thread_return=thread_return at entry=0x7fffffffe518) at pthread_join.c:45
#1  0x00007ffff07ea3a0 in thrd_join (res=0x0, thr=<optimized out>) at ../../../../include/c11/threads_posix.h:336
#2  pipe_thread_wait (thread=<optimized out>) at ../../../../src/gallium/auxiliary/os/os_thread.h:80
#3  util_queue_killall_and_wait (queue=0x5555557d9a48) at ../../../../src/gallium/auxiliary/util/u_queue.c:253
#4  atexit_handler () at ../../../../src/gallium/auxiliary/util/u_queue.c:53
#5  0x00007ffff47df920 in __run_exit_handlers (status=0, listp=0x7ffff4b425d8 <__exit_funcs>, run_list_atexit=run_list_atexit at entry=true, run_dtors=run_dtors at entry=true) at exit.c:83
#6  0x00007ffff47df97a in __GI_exit (status=<optimized out>) at exit.c:105
#7  0x0000555555555793 in main (argc=2, argv=0x7fffffffe6a8) at /home/daenzer/src/piglit-git/piglit/tests/spec/glx_ext_import_context/make-current-single-process.c:55
(gdb) frame 3
#3  util_queue_killall_and_wait (queue=0x5555557d9a48) at ../../../../src/gallium/auxiliary/util/u_queue.c:253
253	      pipe_thread_wait(queue->threads[i]);
(gdb) l
248	   queue->kill_threads = 1;
249	   pipe_condvar_broadcast(queue->has_queued_cond);
250	   pipe_mutex_unlock(queue->lock);
251	
252	   for (i = 0; i < queue->num_threads; i++)
253	      pipe_thread_wait(queue->threads[i]);
254	}
255	
256	void
257	util_queue_destroy(struct util_queue *queue)
(gdb) p queue
$1 = (struct util_queue *) 0x5555557d9a48
(gdb) p *queue
$2 = {name = 0x7ffff0c83a5a "si_shader", lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 4, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, 
    __size = '\000' <repeats 12 times>, "\004", '\000' <repeats 26 times>, __align = 0}, has_queued_cond = {__data = {__lock = 0, __futex = 8, __total_seq = 4, __wakeup_seq = 4, __woken_seq = 4, __mutex = 0x5555557d9a50, __nwaiters = 8, __broadcast_seq = 1}, 
    __size = "\000\000\000\000\b\000\000\000\004\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000P\232}UUU\000\000\b\000\000\000\001\000\000", __align = 34359738368}, has_space_cond = {__data = {__lock = 0, 
      __futex = 0, __total_seq = 0, __wakeup_seq = 0, __woken_seq = 0, __mutex = 0x0, __nwaiters = 0, __broadcast_seq = 0}, __size = '\000' <repeats 47 times>, __align = 0}, threads = 0x5555557e2750, num_queued = 0, num_threads = 4, kill_threads = 1, 
  max_jobs = 32, write_idx = 0, read_idx = 0, jobs = 0x5555557e2340, head = {prev = 0x7ffff1147cb0 <queue_list>, next = 0x5555557d8b98}}
[...]
(gdb) p *queue->threads at 4
$7 = {140737155335936, 140737146943232, 140737138550528, 140737130157824}


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the mesa-dev mailing list