Xpra: Ticket #462: x264 encoder threading related memory corruption and crash

Hard to reproduce:

gdb shows:

Program received signal SIGABRT, Aborted.
0x00000034528359e9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56	  return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) bt
#0  0x00000034528359e9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00000034528370f8 in __GI_abort () at abort.c:90
#2  0x0000003452875d17 in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x345297e568 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/unix/sysv/linux/libc_fatal.c:196
#3  0x000000345287d0b8 in malloc_printerr (ptr=<optimized out>, str=0x345297e640 "double free or corruption (!prev)", action=3) at malloc.c:4937
#4  _int_free (av=0x3452bba780 <main_arena>, p=<optimized out>, have_lock=0) at malloc.c:3789
#5  0x00000039682ad0ac in ?? () from /lib64/libGL.so.1
#6  0x000000396580117a in ?? () from /lib64/tls/libnvidia-tls.so.319.49
#7  0x0000003453d08176 in PyThread_start_new_thread () from /lib64/libpython2.7.so.1.0
#8  0x0000003453d0c117 in ?? () from /lib64/libpython2.7.so.1.0
#9  0x0000003453cddcee in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#10 0x0000003453cdd80c in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#11 0x0000003453cdec7d in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#12 0x0000003453c6dca0 in ?? () from /lib64/libpython2.7.so.1.0
#13 0x0000003453c49dd3 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#14 0x0000003453cd8af7 in PyEval_CallObjectWithKeywords () from /lib64/libpython2.7.so.1.0
#15 0x00007fbbeb778709 in _pyglib_handler_marshal (user_data=0x3d19a28) at pyglib.c:532
#16 0x0000003454c47e06 in g_main_dispatch (context=0x2e2d740) at gmain.c:3054
#17 g_main_context_dispatch (context=context@entry=0x2e2d740) at gmain.c:3630
#18 0x0000003454c48158 in g_main_context_iterate (context=0x2e2d740, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3701
#19 0x0000003454c4855a in g_main_loop_run (loop=0x3c58c90) at gmain.c:3895
#20 0x00000039e353edf7 in gtk_main () from /lib64/libgtk-x11-2.0.so.0
#21 0x00007fbbea7fec27 in _wrap_gtk_main () from /usr/lib64/python2.7/site-packages/gtk-2.0/gtk/_gtk.so
#22 0x0000003453cddabc in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#23 0x0000003453cdd80c in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#24 0x0000003453cdec7d in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#25 0x0000003453cdd769 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#26 0x0000003453cdec7d in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#27 0x0000003453cdd769 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#28 0x0000003453cdd80c in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#29 0x0000003453cdd80c in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#30 0x0000003453cdec7d in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#31 0x0000003453cded82 in PyEval_EvalCode () from /lib64/libpython2.7.so.1.0
#32 0x0000003453cf78af in ?? () from /lib64/libpython2.7.so.1.0
#33 0x0000003453cf89ce in PyRun_FileExFlags () from /lib64/libpython2.7.so.1.0
#34 0x0000003453cf9b39 in PyRun_SimpleFileExFlags () from /lib64/libpython2.7.so.1.0
#35 0x0000003453d0a66f in Py_Main () from /lib64/libpython2.7.so.1.0
#36 0x0000003452821b45 in __libc_start_main (main=0x4006f0, argc=7, ubp_av=0x7fff73250888, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
    stack_end=0x7fff73250878) at libc-start.c:274
#37 0x0000000000400721 in ?? ()
#38 0x00007fff73250878 in ?? ()
#39 0x000000000000001c in ?? ()
#40 0x0000000000000007 in ?? ()
#41 0x00007fff732510b6 in ?? ()
#42 0x00007fff732510c2 in ?? ()
#43 0x00007fff732510d0 in ?? ()
#44 0x00007fff732510d6 in ?? ()
#45 0x00007fff732510da in ?? ()
#46 0x00007fff732510e6 in ?? ()

Turning off x264 threading seems to prevent the crash:

XPRA_X264_THREADS=1 xpra ...

So we should probably make this the default.

Note: the value of "1" forces x264 to use a single thread, "0" means auto and other positive values specify the number of threads exactly.

What does bother me though is the presence of:

/lib64/tls/libnvidia-tls.so.319.49

in the PyThread_start_new_thread call stack. I hope this isn't caused by nvidia drivers. (we have enough TLS problems already)



Tue, 26 Nov 2013 12:16:53 GMT - Antoine Martin: status, description changed; resolution set

Was probably a bug in the Nvidia driver's TLS code. Closing.


Sat, 23 Jan 2021 04:56:17 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/462