xpra icon
Bug tracker and wiki

Opened 8 years ago

Closed 8 years ago

#187 closed defect (fixed)

x264 crashes when resizing window

Reported by: Antoine Martin Owned by: Antoine Martin
Priority: major Milestone: 0.7
Component: server Version: trunk
Keywords: Cc:

Description


Attachments (6)

xpra-video-reinit-and-drop-speed.patch (1.4 KB) - added by Antoine Martin 8 years ago.
patch that removes the code which tries to preserve the encoding speed when we have to clean the encoder
xpra-configuredamage-via-idleadd.patch (983 bytes) - added by Antoine Martin 8 years ago.
calls damage via idle_add so the main loop gets a chance to run and process events
xpra-video-notuning.patch (503 bytes) - added by Antoine Martin 8 years ago.
disables tuning of encoding speed and quality
xpra-composite-warning.patch (637 bytes) - added by Antoine Martin 8 years ago.
make sure we get to see composite errors sooner
valgrind-log.txt (15.5 KB) - added by Antoine Martin 8 years ago.
running the server on Fedora 18 under valgrind
add-x264-debug.patch (2.3 KB) - added by Antoine Martin 8 years ago.
patch used to produce debug

Download all attachments as: .zip

Change History (14)

Changed 8 years ago by Antoine Martin

patch that removes the code which tries to preserve the encoding speed when we have to clean the encoder

Changed 8 years ago by Antoine Martin

calls damage via idle_add so the main loop gets a chance to run and process events

Changed 8 years ago by Antoine Martin

Attachment: xpra-video-notuning.patch added

disables tuning of encoding speed and quality

Changed 8 years ago by Antoine Martin

make sure we get to see composite errors sooner

comment:1 Changed 8 years ago by Antoine Martin

Status: newaccepted

Until I can reproduce this myself, please try applying xpra-composite-warning.patch​ (to get more debug info without needing "-d all") and test the other 3 patches one by one, they can be cumulated.
Hopefully one of those will make a difference to help me narrow it down.

comment:2 Changed 8 years ago by Antoine Martin

Only crashes on Fedora 18 (tested with r1779 server) when connecting from a win32 client (tested with r1786), got a backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x00007f3417394ecc in x264_frame_delete () from /lib64/libx264.so.125
(gdb) bt
#0  0x00007f3417394ecc in x264_frame_delete () from /lib64/libx264.so.125
#1  0x00007f3417398f39 in x264_frame_delete_list () from /lib64/libx264.so.125
#2  0x00007f3417404ec9 in x264_encoder_close () from /lib64/libx264.so.125
#3  0x00007f3415ce0f18 in do_clean_encoder (ctx=ctx@entry=0x7f33e0011290)
    at xpra/x264/x264lib.c:212
#4  0x00007f3415ce0f39 in clean_encoder (ctx=0x7f33e0011290)
    at xpra/x264/x264lib.c:202
#5  0x00007f3415cdca52 in __pyx_pf_4xpra_4x264_5codec_7Encoder_2clean (
    __pyx_v_self=<optimized out>) at xpra/x264/codec.c:2572
#6  __pyx_pw_4xpra_4x264_5codec_7Encoder_3clean (__pyx_v_self=0x7f3410bc7270, 
    unused=<optimized out>) at xpra/x264/codec.c:2536
#7  0x0000003bfc6dcfd6 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#8  0x0000003bfc6dcef1 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#9  0x0000003bfc6dcef1 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#10 0x0000003bfc6dcef1 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#11 0x0000003bfc6dcef1 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#12 0x0000003bfc6ddcbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#13 0x0000003bfc66d926 in ?? () from /lib64/libpython2.7.so.1.0
#14 0x0000003bfc649c0e in PyObject_Call () from /lib64/libpython2.7.so.1.0
#15 0x0000003bfc6d7367 in PyEval_CallObjectWithKeywords ()
   from /lib64/libpython2.7.so.1.0
#16 0x00007f3419837708 in _pyglib_handler_marshal ()
   from /lib64/libpyglib-2.0-python.so.0
---Type <return> to continue, or q <return> to quit---
#17 0x0000003bfca47a95 in g_main_context_dispatch ()
   from /lib64/libglib-2.0.so.0
#18 0x0000003bfca47dc8 in g_main_context_iterate.isra.24 ()
   from /lib64/libglib-2.0.so.0
#19 0x0000003bfca481c2 in g_main_loop_run () from /lib64/libglib-2.0.so.0
#20 0x0000003c0bb4ab47 in gtk_main () from /lib64/libgtk-x11-2.0.so.0
#21 0x00007f341536e298 in _wrap_gtk_main ()
   from /usr/lib64/python2.7/site-packages/gtk-2.0/gtk/_gtk.so
#22 0x0000003bfc6dcfd6 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#23 0x0000003bfc6dcef1 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#24 0x0000003bfc6ddcbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#25 0x0000003bfc6dc2b3 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#26 0x0000003bfc6ddcbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#27 0x0000003bfc6dc2b3 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#28 0x0000003bfc6ddcbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#29 0x0000003bfc6ddd92 in PyEval_EvalCode () from /lib64/libpython2.7.so.1.0
#30 0x0000003bfc6f6f7a in ?? () from /lib64/libpython2.7.so.1.0
#31 0x0000003bfc6f7d72 in PyRun_FileExFlags () from /lib64/libpython2.7.so.1.0
#32 0x0000003bfc6f878b in PyRun_SimpleFileExFlags ()
   from /lib64/libpython2.7.so.1.0
#33 0x0000003bfc709c52 in Py_Main () from /lib64/libpython2.7.so.1.0
#34 0x0000003bfa621a05 in __libc_start_main () from /lib64/libc.so.6
#35 0x0000000000400721 in _start ()

So, we end up calling xpra.x264.codec.Encoder.clean() which crashes somewhere in x264 code.. (x264_frame_delete)

Changed 8 years ago by Antoine Martin

Attachment: valgrind-log.txt added

running the server on Fedora 18 under valgrind

comment:3 Changed 8 years ago by Antoine Martin

Only marginally different stacktrace, still crashing in x264_frame_delete:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f7ce37fe700 (LWP 17864)]
0x0000000000010390 in ?? ()
(gdb) bt
#0  0x0000000000010390 in ?? ()
#1  0x00007f7cf6088ece in x264_frame_delete () from /lib64/libx264.so.125
#2  0x00007f7cf608cf39 in x264_frame_delete_list () from /lib64/libx264.so.125
#3  0x00007f7cf60f8ec9 in x264_encoder_close () from /lib64/libx264.so.125
#4  0x00007f7cf3dfaf68 in do_clean_encoder (ctx=ctx@entry=0x7f7cd0001c90) at xpra/x264/x264lib.c:212
#5  0x00007f7cf3dfaf89 in clean_encoder (ctx=0x7f7cd0001c90) at xpra/x264/x264lib.c:202
#6  0x00007f7cf3df6a52 in __pyx_pf_4xpra_4x264_5codec_7Encoder_2clean (__pyx_v_self=<optimized out>) at xpra/x264/codec.c:2572
#7  __pyx_pw_4xpra_4x264_5codec_7Encoder_3clean (__pyx_v_self=0x16dd780, unused=<optimized out>) at xpra/x264/codec.c:2536
#8  0x00007f7d04a89fd6 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#9  0x00007f7d04a89ef1 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#10 0x00007f7d04a8acbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#11 0x00007f7d04a1a926 in ?? () from /lib64/libpython2.7.so.1.0
#12 0x00007f7d049f6c0e in PyObject_Call () from /lib64/libpython2.7.so.1.0
#13 0x00007f7d04a8708b in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#14 0x00007f7d04a8acbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#15 0x00007f7d04a892b3 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#16 0x00007f7d04a8acbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#17 0x00007f7d04a1aa37 in ?? () from /lib64/libpython2.7.so.1.0
#18 0x00007f7d049f6c0e in PyObject_Call () from /lib64/libpython2.7.so.1.0
#19 0x00007f7d04a8708b in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#20 0x00007f7d04a89ef1 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#21 0x00007f7d04a89ef1 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#22 0x00007f7d04a8acbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#23 0x00007f7d04a1a926 in ?? () from /lib64/libpython2.7.so.1.0
#24 0x00007f7d049f6c0e in PyObject_Call () from /lib64/libpython2.7.so.1.0
#25 0x00007f7d04a05200 in ?? () from /lib64/libpython2.7.so.1.0
#26 0x00007f7d049f6c0e in PyObject_Call () from /lib64/libpython2.7.so.1.0
#27 0x00007f7d04a84367 in PyEval_CallObjectWithKeywords () from /lib64/libpython2.7.so.1.0
#28 0x00007f7d04ab8802 in ?? () from /lib64/libpython2.7.so.1.0
#29 0x00007f7d04798d15 in start_thread () from /lib64/libpthread.so.0
#30 0x00007f7d03dc32cd in clone () from /lib64/libc.so.6

comment:4 Changed 8 years ago by Antoine Martin

This time from a different codepath: set_encoding_quality (but still where we hold the video lock):

#0  0x0000000000000001 in ?? ()
#1  0x00007fb451813ece in x264_frame_delete () from /lib64/libx264.so.125
#2  0x00007fb451817f39 in x264_frame_delete_list () from /lib64/libx264.so.125
#3  0x00007fb451883ec9 in x264_encoder_close () from /lib64/libx264.so.125
#4  0x00007fb44ff38f68 in do_clean_encoder (ctx=ctx@entry=0x7fb434002ce0) at xpra/x264/x264lib.c:212
#5  0x00007fb44ff39784 in set_encoding_quality (ctx=0x7fb434002ce0, pct=100) at xpra/x264/x264lib.c:466
#6  0x00007fb44ff3682e in __pyx_pf_4xpra_4x264_5codec_7Encoder_10set_encoding_quality (
    __pyx_v_pct=<optimized out>, __pyx_v_self=<optimized out>) at xpra/x264/codec.c:3279
#7  __pyx_pw_4xpra_4x264_5codec_7Encoder_11set_encoding_quality (__pyx_v_self=0x21cd3f0, 
    __pyx_v_pct=<optimized out>) at xpra/x264/codec.c:3200
#8  0x0000003bfc6dd1e3 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#9  0x0000003bfc6ddcbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#10 0x0000003bfc6dc2b3 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#11 0x0000003bfc6dcef1 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#12 0x0000003bfc6ddcbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#13 0x0000003bfc6dc2b3 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#14 0x0000003bfc6ddcbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#15 0x0000003bfc6dc2b3 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#16 0x0000003bfc6ddcbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#17 0x0000003bfc6dc2b3 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#18 0x0000003bfc6ddcbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#19 0x0000003bfc66d926 in ?? () from /lib64/libpython2.7.so.1.0
#20 0x0000003bfc649c0e in PyObject_Call () from /lib64/libpython2.7.so.1.0
#21 0x0000003bfc6d7367 in PyEval_CallObjectWithKeywords () from /lib64/libpython2.7.so.1.0
#22 0x00007fb453f06708 in _pyglib_handler_marshal () from /lib64/libpyglib-2.0-python.so.0
#23 0x0000003bfca47a95 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#24 0x0000003bfca47dc8 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
#25 0x0000003bfca481c2 in g_main_loop_run () from /lib64/libglib-2.0.so.0
#26 0x0000003c0bb4ab47 in gtk_main () from /lib64/libgtk-x11-2.0.so.0
#27 0x00007fb44f06c298 in _wrap_gtk_main () from /usr/lib64/python2.7/site-packages/gtk-2.0/gtk/_gtk.so
#28 0x0000003bfc6dcfd6 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#29 0x0000003bfc6dcef1 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#30 0x0000003bfc6ddcbf in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#31 0x0000003bfc6dc2b3 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0

And with some debug added (just closing the window crashes it):

init_encoder(498, 316, 70, 1)
do_init_encoder(0x7f9ba80018e0, 498, 316, 70, 1)
init_encoder_csc(0x7f9ba80018e0) rgb2yuv=(nil)
init_context(498, 316, 1)
[swscaler @ 0x7f9ba8686ee0] Warning: data is not aligned! This can lead to a speedloss
do_clean_encoder(0x7f9ba80018e0) rgb2yuv=0x7f9ba8686ee0, encoder=0x7f9ba8001950
do_init_encoder(0x7f9ba80018e0, 498, 316, 100, 1)
init_encoder_csc(0x7f9ba80018e0) rgb2yuv=(nil)
init_encoder(498, 316, 70, 1)
do_init_encoder(0x7f9ba8692f20, 498, 316, 70, 1)
init_encoder_csc(0x7f9ba8692f20) rgb2yuv=(nil)
init_context(498, 316, 1)
do_clean_encoder(0x7f9ba8692f20) rgb2yuv=0x7f9ba8627ea0, encoder=0x7f9ba8001950
do_init_encoder(0x7f9ba8692f20, 498, 316, 100, 1)
init_encoder_csc(0x7f9ba8692f20) rgb2yuv=(nil)
clean() context exists=True
clean_encoder(0x7f9ba80018e0)
do_clean_encoder(0x7f9ba80018e0) rgb2yuv=0x326cfc0, encoder=0x27c3a30
Segmentation fault (core dumped)

Changed 8 years ago by Antoine Martin

Attachment: add-x264-debug.patch added

patch used to produce debug

comment:5 Changed 8 years ago by Antoine Martin

First, install debug info:

debuginfo-install python-2.7.3-13.fc18.x86_64

Then you get this more complete backtrace:

#0  0x0000003bfc983ea0 in _Py_NoneStruct () from /lib64/libpython2.7.so.1.0
#1  0x00007fb8cb9d4f4e in x264_frame_delete (frame=0x7fb8b0d1a730) at common/frame.c:305
#2  0x00007fb8cb9d8fb9 in x264_frame_delete_list (list=0x7fb8b0000f40) at common/frame.c:774
#3  0x00007fb8cba44f49 in x264_encoder_close (h=0x7fb8b0001a50) at encoder/encoder.c:3804
#4  0x00007fb8ca311e20 in do_clean_encoder (ctx=ctx@entry=0x7fb8b00019e0) at xpra/x264/x264lib.c:218
#5  0x00007fb8ca311e5c in clean_encoder (ctx=0x7fb8b00019e0) at xpra/x264/x264lib.c:206
#6  0x00007fb8ca30e1c8 in __pyx_pf_4xpra_4x264_5codec_7Encoder_2clean (__pyx_v_self=<optimized out>)
    at xpra/x264/codec.c:2630
#7  __pyx_pw_4xpra_4x264_5codec_7Encoder_3clean (__pyx_v_self=<xpra.x264.codec.Encoder at remote 0x2cf5f60>, 
    unused=<optimized out>) at xpra/x264/codec.c:2574
#8  0x0000003bfc6dcfd6 in call_function (oparg=<optimized out>, pp_stack=0x7fb8c4a1e858)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:4082
#9  PyEval_EvalFrameEx (f=<optimized out>, throwflag=throwflag@entry=0)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:2740
#10 0x0000003bfc6dcef1 in fast_function (nk=<optimized out>, na=1, n=<optimized out>, pp_stack=0x7fb8c4a1ea58, 
    func=<function at remote 0x2bbbaa0>) at /usr/src/debug/Python-2.7.3/Python/ceval.c:4184
#11 call_function (oparg=<optimized out>, pp_stack=0x7fb8c4a1ea58)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:4119
#12 PyEval_EvalFrameEx (f=<optimized out>, throwflag=throwflag@entry=0)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:2740
#13 0x0000003bfc6dcef1 in fast_function (nk=<optimized out>, na=10, n=<optimized out>, pp_stack=
    0x7fb8c4a1ec58, func=<function at remote 0x2bbd7d0>) at /usr/src/debug/Python-2.7.3/Python/ceval.c:4184
#14 call_function (oparg=<optimized out>, pp_stack=0x7fb8c4a1ec58)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:4119
#15 PyEval_EvalFrameEx (f=f@entry=
    Frame 0x7fb8b00011e0, for file /usr/lib64/python2.7/site-packages/xpra/window_source.py, line 732, in make_data_packet (self=<WindowSource(wid=1, encoding='x264', _sequence=5, _last_sequence_queued=4, refresh_timer=None, encodings=['x264', 'vpx', 'png', 'jpeg', 'rgb24', 'webp'], uses_swscale=True, statistics=<WindowPerformanceStatistics(damage_send_speed=<collections.deque at remote 0x2d70130>, encoding_totals={'x264': [2, 396144], 'png': [1, 78]}, damage_in_latency=<collections.deque at remote 0x2d70050>, client_decode_time=<collections.deque at remote 0x2c22f30>, encoding_stats=<collections.deque at remote 0x2c22fa0>, damage_ack_pending={}, damage_out_latency=<collections.deque at remote 0x2d700c0>) at remote 0x2cd9dd0>, _video_encoder=<xpra.x264.codec.Encoder at remote 0x2cf5f60>, default_damage_options={}, global_statistics=<GlobalPerformanceStatistics(mmap_free_size=0, mmap_bytes_sent=0, client_decode_time=<collections.deque at remote 0x2c22c90>, client_latency=<collections.deque at r---Type <return> to continue, or q <return> to quit---
emote 0x2c22d00>, se...(truncated), throwflag=throwflag@entry=0)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:2740
#16 0x0000003bfc6ddcbf in PyEval_EvalCodeEx (co=<optimized out>, globals=<optimized out>, locals=locals@entry=
    0x0, args=args@entry=0x2bcfc48, argcount=13, kws=kws@entry=0x0, kwcount=kwcount@entry=0, defs=defs@entry=
    0x0, defcount=defcount@entry=0, closure=0x0) at /usr/src/debug/Python-2.7.3/Python/ceval.c:3330
#17 0x0000003bfc66d926 in function_call (func=<function at remote 0x2bbd578>, arg=
    (<WindowSource(wid=1, encoding='x264', _sequence=5, _last_sequence_queued=4, refresh_timer=None, encodings=['x264', 'vpx', 'png', 'jpeg', 'rgb24', 'webp'], uses_swscale=True, statistics=<WindowPerformanceStatistics(damage_send_speed=<collections.deque at remote 0x2d70130>, encoding_totals={'x264': [2, 396144], 'png': [1, 78]}, damage_in_latency=<collections.deque at remote 0x2d70050>, client_decode_time=<collections.deque at remote 0x2c22f30>, encoding_stats=<collections.deque at remote 0x2c22fa0>, damage_ack_pending={}, damage_out_latency=<collections.deque at remote 0x2d700c0>) at remote 0x2cd9dd0>, _video_encoder=<xpra.x264.codec.Encoder at remote 0x2cf5f60>, default_damage_options={}, global_statistics=<GlobalPerformanceStatistics(mmap_free_size=0, mmap_bytes_sent=0, client_decode_time=<collections.deque at remote 0x2c22c90>, client_latency=<collections.deque at remote 0x2c22d00>, server_ping_latency=<collections.deque at remote 0x2c22de0>, avg_client_latency=<float at remote 0x2df1260>, client_ping_laten...(truncated), kw=0x0) at /usr/src/debug/Python-2.7.3/Objects/funcobject.c:526
#18 0x0000003bfc649c0e in PyObject_Call (func=func@entry=<function at remote 0x2bbd578>, arg=<optimized out>, 
    kw=kw@entry=0x0) at /usr/src/debug/Python-2.7.3/Objects/abstract.c:2529
#19 0x0000003bfc6da08b in ext_do_call (nk=0, na=<optimized out>, flags=<optimized out>, pp_stack=
    0x7fb8c4a1efd8, func=<function at remote 0x2bbd578>) at /usr/src/debug/Python-2.7.3/Python/ceval.c:4411
#20 PyEval_EvalFrameEx (f=f@entry=
    Frame 0x7fb8b0000f80, for file /usr/lib64/python2.7/site-packages/xpra/window_source.py, line 601, in make_data_packet (args=()), throwflag=throwflag@entry=0) at /usr/src/debug/Python-2.7.3/Python/ceval.c:2779
#21 0x0000003bfc6ddcbf in PyEval_EvalCodeEx (co=<optimized out>, globals=<optimized out>, locals=locals@entry=
    0x0, args=<optimized out>, argcount=argcount@entry=0, kws=0x2b083d8, kwcount=0, defs=0x0, defcount=0, 
    closure=
    (<cell at remote 0x2d82b08>, <cell at remote 0x2d82ad0>, <cell at remote 0x2d82a98>, <cell at remote 0x2d82a60>, <cell at remote 0x2d82a28>, <cell at remote 0x2d82b40>, <cell at remote 0x2d82b78>, <cell at remote 0x2d82bb0>, <cell at remote 0x2d82be8>, <cell at remote 0x2d82c20>))
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:3330
#22 0x0000003bfc6dc2b3 in fast_function (nk=<optimized out>, na=0, n=<optimized out>, pp_stack=0x7fb8c4a1f288, 
    func=<function at remote 0x2d8d2a8>) at /usr/src/debug/Python-2.7.3/Python/ceval.c:4194
#23 call_function (oparg=<optimized out>, pp_stack=0x7fb8c4a1f288)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:4119
---Type <return> to continue, or q <return> to quit---
#24 PyEval_EvalFrameEx (f=f@entry=
    Frame 0x2b08240, for file /usr/lib64/python2.7/site-packages/xpra/server_source.py, line 862, in data_to_packet (self=<ServerSource(protocol=<Protocol(_read_queue=<Queue(unfinished_tasks=29, queue=<collections.deque at remote 0x2c228a0>, maxsize=5, all_tasks_done=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd4130>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd4130>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x2cd4130>) at remote 0x2cd0cd0>, mutex=<thread.lock at remote 0x2cd4130>, not_full=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd4130>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd4130>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x2cd4130>) at remote 0x2cd0c90>, not_empty=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd4130>, acquire=<built-in method acquire ...(truncated), throwflag=throwflag@entry=0)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:2740
#25 0x0000003bfc6ddcbf in PyEval_EvalCodeEx (co=<optimized out>, globals=<optimized out>, locals=locals@entry=
    0x0, args=args@entry=0x2cd9ba8, argcount=1, kws=kws@entry=0x7fb8d18de068, kwcount=kwcount@entry=0, 
    defs=defs@entry=0x0, defcount=defcount@entry=0, closure=0x0)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:3330
#26 0x0000003bfc66da37 in function_call (func=<function at remote 0x2bc75f0>, arg=
    (<ServerSource(protocol=<Protocol(_read_queue=<Queue(unfinished_tasks=29, queue=<collections.deque at remote 0x2c228a0>, maxsize=5, all_tasks_done=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd4130>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd4130>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x2cd4130>) at remote 0x2cd0cd0>, mutex=<thread.lock at remote 0x2cd4130>, not_full=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd4130>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd4130>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x2cd4130>) at remote 0x2cd0c90>, not_empty=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd4130>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd4130>, _Condition__waiters=[<thread.lock at remote 0x2cd4330>], release=<built-i...(truncated), kw={}) at /usr/src/debug/Python-2.7.3/Objects/funcobject.c:526
#27 0x0000003bfc649c0e in PyObject_Call (func=func@entry=<function at remote 0x2bc75f0>, arg=<optimized out>, 
    kw=kw@entry={}) at /usr/src/debug/Python-2.7.3/Objects/abstract.c:2529
#28 0x0000003bfc6da08b in ext_do_call (nk=0, na=<optimized out>, flags=<optimized out>, pp_stack=
    0x7fb8c4a1f608, func=<function at remote 0x2bc75f0>) at /usr/src/debug/Python-2.7.3/Python/ceval.c:4411
#29 PyEval_EvalFrameEx (f=<optimized out>, throwflag=throwflag@entry=0)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:2779
#30 0x0000003bfc6dcef1 in fast_function (nk=<optimized out>, na=1, n=<optimized out>, pp_stack=0x7fb8c4a1f808, 
---Type <return> to continue, or q <return> to quit---
    func=<function at remote 0x7fb8ceb557d0>) at /usr/src/debug/Python-2.7.3/Python/ceval.c:4184
#31 call_function (oparg=<optimized out>, pp_stack=0x7fb8c4a1f808)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:4119
#32 PyEval_EvalFrameEx (f=<optimized out>, throwflag=throwflag@entry=0)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:2740
#33 0x0000003bfc6dcef1 in fast_function (nk=<optimized out>, na=1, n=<optimized out>, pp_stack=0x7fb8c4a1fa08, 
    func=<function at remote 0x7fb8ceb55938>) at /usr/src/debug/Python-2.7.3/Python/ceval.c:4184
#34 call_function (oparg=<optimized out>, pp_stack=0x7fb8c4a1fa08)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:4119
#35 PyEval_EvalFrameEx (f=f@entry=
    Frame 0x7fb8b0000910, for file /usr/lib64/python2.7/threading.py, line 524, in __bootstrap (self=<Thread(_Thread__ident=140431549662976, _Thread__block=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd42f0>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd42f0>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x2cd42f0>) at remote 0x2cd9bd0>, _Thread__name='data_to_packet', _Thread__daemonic=True, _Thread__started=<_Event(_Verbose__verbose=False, _Event__flag=True, _Event__cond=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd42d0>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd42d0>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x2cd42d0>) at remote 0x2cd9b50>) at remote 0x2cd9b10>, _Thread__stderr=<file at remote 0x7fb8d18f6270>, _Thread__target=<instancemethod at remote 0x2cd7370>, _Thread__kwargs={}, _Verbose__v...(truncated), throwflag=throwflag@entry=0)
    at /usr/src/debug/Python-2.7.3/Python/ceval.c:2740
#36 0x0000003bfc6ddcbf in PyEval_EvalCodeEx (co=<optimized out>, globals=<optimized out>, locals=locals@entry=
    0x0, args=args@entry=0x2cd91e8, argcount=1, kws=kws@entry=0x0, kwcount=kwcount@entry=0, defs=defs@entry=
    0x0, defcount=defcount@entry=0, closure=0x0) at /usr/src/debug/Python-2.7.3/Python/ceval.c:3330
#37 0x0000003bfc66d926 in function_call (func=<function at remote 0x7fb8ceb55848>, arg=
    (<Thread(_Thread__ident=140431549662976, _Thread__block=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd42f0>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd42f0>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x2cd42f0>) at remote 0x2cd9bd0>, _Thread__name='data_to_packet', _Thread__daemonic=True, _Thread__started=<_Event(_Verbose__verbose=False, _Event__flag=True, _Event__cond=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd42d0>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd42d0>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x2cd42d0>) at remote 0x2cd9b50>) at remote 0x2cd9b10>, _Thread__stderr=<file at remote 0x7fb8d18f6270>, _Thread__target=<instancemethod at remote 0x2cd7370>, _Thread__kwargs={}, _Verbose__verbose=False, _Thread__args=(), _Thread__stopped=False, _Thread__initialized---Type <return> to continue, or q <return> to quit---
=True) at remote 0x2...(truncated), kw=0x0) at /usr/src/debug/Python-2.7.3/Objects/funcobject.c:526
#38 0x0000003bfc649c0e in PyObject_Call (func=func@entry=<function at remote 0x7fb8ceb55848>, arg=arg@entry=
    (<Thread(_Thread__ident=140431549662976, _Thread__block=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd42f0>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd42f0>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x2cd42f0>) at remote 0x2cd9bd0>, _Thread__name='data_to_packet', _Thread__daemonic=True, _Thread__started=<_Event(_Verbose__verbose=False, _Event__flag=True, _Event__cond=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd42d0>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd42d0>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x2cd42d0>) at remote 0x2cd9b50>) at remote 0x2cd9b10>, _Thread__stderr=<file at remote 0x7fb8d18f6270>, _Thread__target=<instancemethod at remote 0x2cd7370>, _Thread__kwargs={}, _Verbose__verbose=False, _Thread__args=(), _Thread__stopped=False, _Thread__initialized=True) at remote 0x2...(truncated), kw=kw@entry=0x0) at /usr/src/debug/Python-2.7.3/Objects/abstract.c:2529
#39 0x0000003bfc658200 in instancemethod_call (func=<function at remote 0x7fb8ceb55848>, arg=
    (<Thread(_Thread__ident=140431549662976, _Thread__block=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd42f0>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd42f0>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x2cd42f0>) at remote 0x2cd9bd0>, _Thread__name='data_to_packet', _Thread__daemonic=True, _Thread__started=<_Event(_Verbose__verbose=False, _Event__flag=True, _Event__cond=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x2cd42d0>, acquire=<built-in method acquire of thread.lock object at remote 0x2cd42d0>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x2cd42d0>) at remote 0x2cd9b50>) at remote 0x2cd9b10>, _Thread__stderr=<file at remote 0x7fb8d18f6270>, _Thread__target=<instancemethod at remote 0x2cd7370>, _Thread__kwargs={}, _Verbose__verbose=False, _Thread__args=(), _Thread__stopped=False, _Thread__initialized=True) at remote 0x2...(truncated), kw=0x0) at /usr/src/debug/Python-2.7.3/Objects/classobject.c:2578
#40 0x0000003bfc649c0e in PyObject_Call (func=func@entry=<instancemethod at remote 0x2cd73c0>, arg=arg@entry=
    (), kw=<optimized out>) at /usr/src/debug/Python-2.7.3/Objects/abstract.c:2529
#41 0x0000003bfc6d7367 in PyEval_CallObjectWithKeywords (func=<instancemethod at remote 0x2cd73c0>, arg=(), 
    kw=<optimized out>) at /usr/src/debug/Python-2.7.3/Python/ceval.c:3967
#42 0x0000003bfc70b802 in t_bootstrap (boot_raw=0x2d40a00)
    at /usr/src/debug/Python-2.7.3/Modules/threadmodule.c:614
#43 0x0000003bfae07d15 in start_thread () from /lib64/libpthread.so.0
#44 0x0000003bfa6f22cd in clone () from /lib64/libc.so.6

comment:6 Changed 8 years ago by Antoine Martin

Nasty bug found!

Built x264-libs from rpm source to get the exact line number, which was this one:

param->param-param_free( frame->param );

And as it happens, this x264_param_t instance is allocated in our code as a local variable on the heap.. when we call compress_image with a quality_override value. This happens a lot now that we have auto-refresh enabled by default.

Will look for more, as it's not really clear to me which ones we're meant to hold on to and which ones we can dispose of because their data gets copied..

comment:7 Changed 8 years ago by Antoine Martin

Fixed in r1872

Other places where we use x264_param_t:

  • x264_encoder_open: "create a new encoder handler, all parameters from x264_param_t are copied" - safe
  • x264_encoder_parameters: "various parameters from x264_param_t are copied" - safe
  • x264_param_apply_profile: unclear from docs (called from set_encoding_speed)
  • x264_encoder_reconfig: unclear from docs (called from set_encoding_speed and set_encoding_quality)

comment:8 Changed 8 years ago by Antoine Martin

Resolution: fixed
Status: acceptedclosed

After manual x264 code inspection:

  • x264_param_apply_profile: only initializes fields in the structure, does not keep any reference to it - safe
  • x264_encoder_reconfig: copies fields into the param structure stored in x264_t - safe
Note: See TracTickets for help on using tickets.