spice/server
Frediano Ziglio 62cc9643c3 gstreamer: Fix infinite loop in get_period_bit_rate
This was discovered by chance by me and Uri trying some remote connection
with slow network (8Mbit) and high latency

  $ ping 10.10.48.87 -c 3
  3 packets transmitted, 3 received, 0% packet loss, time 2002ms
  rtt min/avg/max/mdev = 281.069/316.758/374.413/41.153 ms

The encoder->history status was (edited for readability):

(gdb) p ((SpiceGstEncoder*)0x61c000264880)->history_first
$6 = 29
(gdb) p ((SpiceGstEncoder*)0x61c000264880)->history_last
$14 = 28
(gdb) p ((SpiceGstEncoder*)0x61c000264880)->history
[0] {mm_time = 11298131, duration = 7391006, size = 5616},
[1] {mm_time = 11298148, duration = 7373663, size = 5559},
[2] {mm_time = 11298166, duration = 7052209, size = 5511},
[3] {mm_time = 11298183, duration = 7006828, size = 5722},
[4] {mm_time = 11298199, duration = 7433311, size = 5756},
[5] {mm_time = 11298216, duration = 7134734, size = 5545},
[6] {mm_time = 11298232, duration = 7436589, size = 5521},
[7] {mm_time = 11298249, duration = 7152181, size = 5540},
[8] {mm_time = 11298266, duration = 7181308, size = 7796},
[9] {mm_time = 11298283, duration = 5053084, size = 50824},
[10] {mm_time = 11298298, duration = 7472305, size = 7427},
[11] {mm_time = 11298315, duration = 7385017, size = 6682},
[12] {mm_time = 11298333, duration = 7287125, size = 6377},
[13] {mm_time = 11298349, duration = 7191461, size = 6159},
[14] {mm_time = 11298367, duration = 7104546, size = 6035},
[15] {mm_time = 11298382, duration = 7266942, size = 5896},
[16] {mm_time = 11298400, duration = 7108001, size = 5812},
[17] {mm_time = 11298418, duration = 7020583, size = 5807},
[18] {mm_time = 11298433, duration = 7066056, size = 5758},
[19] {mm_time = 11298450, duration = 7052900, size = 5676},
[20] {mm_time = 11298467, duration = 7248233, size = 5765},
[21] {mm_time = 11298483, duration = 7077348, size = 5712},
[22] {mm_time = 11298502, duration = 7495368, size = 5835},
[23] {mm_time = 11298517, duration = 7068626, size = 5805},
[24] {mm_time = 11298534, duration = 7060375, size = 5801},
[25] {mm_time = 11298551, duration = 7020383, size = 5868},
[26] {mm_time = 11298568, duration = 7248400, size = 5830},
[27] {mm_time = 11298584, duration = 7001304, size = 6621},
[28] {mm_time = 11298600, duration = 7311600, size = 6113},
[29] {mm_time = 11297612, duration = 6999174, size = 5666},  <--- to
[30] {mm_time = 11297628, duration = 7506688, size = 5502},
[31] {mm_time = 11297646, duration = 7209494, size = 5687},
[32] {mm_time = 11297663, duration = 7396429, size = 5724},
[33] {mm_time = 11297679, duration = 7172624, size = 5839},
[34] {mm_time = 11297696, duration = 7300811, size = 5645},
[35] {mm_time = 11297713, duration = 7108985, size = 5553},
[36] {mm_time = 11297729, duration = 7171701, size = 5774},
[37] {mm_time = 11297745, duration = 7174018, size = 5637},
[38] {mm_time = 11297762, duration = 7313549, size = 5655},
[39] {mm_time = 11297780, duration = 5183985, size = 51014},
[40] {mm_time = 11297796, duration = 7038329, size = 7374},
[41] {mm_time = 11297813, duration = 7211506, size = 6585},
[42] {mm_time = 11297830, duration = 7112690, size = 5729},
[43] {mm_time = 11297846, duration = 7103074, size = 5761},
[44] {mm_time = 11297864, duration = 7599826, size = 5661},
[45] {mm_time = 11297879, duration = 7355392, size = 5351},
[46] {mm_time = 11297897, duration = 7454367, size = 5488},
[47] {mm_time = 11297913, duration = 7127145, size = 5573},
[48] {mm_time = 11297932, duration = 7550098, size = 5447},
[49] {mm_time = 11297948, duration = 7506884, size = 5809},
[50] {mm_time = 11297966, duration = 7405712, size = 5783},
[51] {mm_time = 11297982, duration = 7182025, size = 5599},
[52] {mm_time = 11298001, duration = 7323887, size = 5817},
[53] {mm_time = 11298014, duration = 7342091, size = 5575},
[54] {mm_time = 11298031, duration = 7596319, size = 5739},
[55] {mm_time = 11298052, duration = 7428169, size = 5669},
[56] {mm_time = 11298065, duration = 7457282, size = 5732},
[57] {mm_time = 11298081, duration = 7174029, size = 5541},
[58] {mm_time = 11298097, duration = 7340512, size = 5680},
[59] {mm_time = 11298115, duration = 7427439, size = 5701}}
(gdb) p from
$16 = 11297544
(gdb) p to
$17 = 11297612

You can see that encoder->history[encoder->history_first].mm_time == to
cause the check index == encoder->history_first to not be executed.

This code change was suggested by Uri.

Reported-by: Uri Lublin <uril@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Tested-by: Uri Lublin <uril@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-08-11 14:12:21 +01:00
..
tests Constify event_loop_core 2016-06-29 08:08:54 +01:00
.gitignore Update the .gitignore files for the new manual, 2015-10-16 15:48:23 -05:00
agent-msg-filter.c AgentMsgFilter: use typedef 2016-05-24 17:46:05 +01:00
agent-msg-filter.h AgentMsgFilter: use typedef 2016-05-24 17:46:05 +01:00
cache-item.h Move RedCacheItem size field inside cache_data union 2016-05-25 09:53:57 +01:00
cache-item.tmpl.c remove CommonGraphicsChannelClient structure 2016-08-09 10:22:46 -05:00
char-device.c char-device: fix mismatch of client tokens 2016-06-07 18:06:31 +01:00
char-device.h Remove obsolete comment 2016-06-01 16:21:07 +01:00
cursor-channel.c remove CommonGraphicsChannelClient structure 2016-08-09 10:22:46 -05:00
cursor-channel.h Add some comments to cursor-channel.h header 2016-05-27 09:32:58 +01:00
dcc-private.h remove CommonGraphicsChannelClient structure 2016-08-09 10:22:46 -05:00
dcc-send.c move is_low_bandwidth to DisplayChannelClient 2016-08-09 10:22:46 -05:00
dcc.c remove CommonGraphicsChannelClient structure 2016-08-09 10:22:46 -05:00
dcc.h move is_low_bandwidth to DisplayChannelClient 2016-08-09 10:22:46 -05:00
demarshallers.h Make sure all headers are independent 2016-05-18 00:24:37 +01:00
dispatcher.c Fix compiling with defined DEBUG_DISPATCHER 2016-07-01 13:59:36 +02:00
dispatcher.h unify header include order 2016-05-12 11:02:54 +01:00
display-channel.c Miscellaneous header changes 2016-08-09 10:22:46 -05:00
display-channel.h Miscellaneous header changes 2016-08-09 10:22:46 -05:00
display-limits.h worker: start a DisplayChannelClient unit 2015-11-19 12:43:02 +00:00
event-loop.c Constify event_loop_core 2016-06-29 08:08:54 +01:00
glz-encode-match.tmpl.c server: rename _tmpl files 2015-11-26 13:33:36 +00:00
glz-encode.tmpl.c Fix -Werror=format with DEBUG_ENCODE 2016-07-01 14:00:37 +02:00
glz-encoder-dict.c remove glz_encoder_config.h 2015-12-04 11:57:18 +00:00
glz-encoder-dict.h remove glz_encoder_config.h 2015-12-04 11:57:18 +00:00
glz-encoder-priv.h Make sure all headers are independent 2016-05-18 00:24:37 +01:00
glz-encoder.c server: rename files 2015-12-03 23:54:32 +00:00
glz-encoder.h unify header include order 2016-05-12 11:02:54 +01:00
gstreamer-encoder.c gstreamer: Fix infinite loop in get_period_bit_rate 2016-08-11 14:12:21 +01:00
image-cache.c Make some function static 2016-05-25 15:41:58 +01:00
image-cache.h Limit direct access to DisplayChannelClient 2016-08-09 10:22:46 -05:00
image-encoders.c Make RedGlzDrawable typedef private 2016-06-17 20:59:19 +01:00
image-encoders.h Use proper types in compress_send_data_t 2016-06-20 21:51:06 +01:00
inputs-channel-client.c Avoid getting channel from client 2016-05-27 18:02:29 +01:00
inputs-channel-client.h Move InputsChannelClient to a separate file 2016-05-24 14:56:41 -05:00
inputs-channel.c Handle scancode extensions E1 and E2 2016-08-01 15:37:18 +01:00
inputs-channel.h Avoid getting channel from client 2016-05-27 18:02:29 +01:00
jpeg-encoder.c server: rename files 2015-12-03 23:54:32 +00:00
jpeg-encoder.h server: rename files 2015-12-03 23:54:32 +00:00
lz4-encoder.c Move lz4-encoder.[ch] to conditional block in Makefile.am 2016-06-16 11:16:01 -03:00
lz4-encoder.h server: rename files 2015-12-03 23:54:32 +00:00
main-channel-client.c channel: Remove clients_num and use g_list_length 2016-06-01 16:56:16 +01:00
main-channel-client.h move all item creation in main-channel-client.c 2016-05-24 13:41:08 -05:00
main-channel.c channel: Remove clients_num and use g_list_length 2016-06-01 16:56:16 +01:00
main-channel.h Move MainChannelClient to separate file 2016-05-20 09:16:47 -05:00
main-dispatcher.c Convert Dispatcher and MainDispatcher to GObjects 2016-03-30 17:19:24 +01:00
main-dispatcher.h unify header include order 2016-05-12 11:02:54 +01:00
Makefile.am Limit direct access to DisplayChannelClient 2016-08-09 10:22:46 -05:00
memslot.c memslot: do not crash if guest provide a wrong address 2016-02-18 10:36:26 +00:00
memslot.h unify header include order 2016-05-12 11:02:54 +01:00
migration-protocol.h Make sure all headers are independent 2016-05-18 00:24:37 +01:00
mjpeg-encoder.c streaming: Avoid copying the input frame in the GStreamer encoder 2016-06-14 17:04:40 +02:00
pixmap-cache.c Introduce SPICE_UPCAST macro 2016-05-24 18:00:51 +01:00
pixmap-cache.h server: rename files 2015-12-03 23:54:32 +00:00
red-channel.c Fix missing prototypes 2016-06-15 15:02:42 +01:00
red-channel.h channel: Remove clients_num and use g_list_length 2016-06-01 16:56:16 +01:00
red-common.h Constify event_loop_core 2016-06-29 08:08:54 +01:00
red-parse-qxl.c factor out red_validate_surface function to validate surface parameters 2016-06-08 09:59:31 +01:00
red-parse-qxl.h factor out red_validate_surface function to validate surface parameters 2016-06-08 09:59:31 +01:00
red-pipe-item.c make red_pipe_item_unref more typesafe 2016-05-21 04:11:12 +01:00
red-pipe-item.h make red_pipe_item_unref more typesafe 2016-05-21 04:11:12 +01:00
red-qxl.c Fix gl draw command called without scanout 2016-07-13 12:53:43 +01:00
red-qxl.h streaming: Let the administrator pick the video encoder and codec 2016-06-14 17:04:40 +02:00
red-record-qxl.c Miscellaneous header changes 2016-08-09 10:22:46 -05:00
red-record-qxl.h record: Use proper type for timestamp 2016-06-08 15:27:48 +01:00
red-replay-qxl.c replay: Load cursor commands 2016-06-06 09:29:12 +01:00
red-replay-qxl.h unify header include order 2016-05-12 11:02:54 +01:00
red-worker.c move is_low_bandwidth to DisplayChannelClient 2016-08-09 10:22:46 -05:00
red-worker.h remove CommonGraphicsChannelClient structure 2016-08-09 10:22:46 -05:00
reds-private.h Make sure all headers are independent 2016-05-18 00:24:37 +01:00
reds-stream.c use #include<> style for spice-common header inclusions. 2016-05-09 12:45:27 +01:00
reds-stream.h unify header include order 2016-05-12 11:02:54 +01:00
reds.c Call migrate_end_complete() after falling back to switch-host 2016-07-28 11:57:50 +02:00
reds.h streaming: Let the administrator pick the video encoder and codec 2016-06-14 17:04:40 +02:00
smartcard.c smartcard: allocate msg with the expected size 2016-07-08 10:47:38 +02:00
smartcard.h Make sure all headers are independent 2016-05-18 00:24:37 +01:00
sound.c use #include<> style for spice-common header inclusions. 2016-05-09 12:45:27 +01:00
sound.h Make sure all headers are independent 2016-05-18 00:24:37 +01:00
spice-audio.h Split spice.h 2014-11-27 14:27:18 +01:00
spice-bitmap-utils.c do not compile dump_bitmap if not necessary 2016-03-24 13:11:46 +00:00
spice-bitmap-utils.h server: misc header cleanups 2015-12-09 22:17:51 +00:00
spice-bitmap-utils.tmpl.c server: rename _tmpl files 2015-11-26 13:33:36 +00:00
spice-char.h Constify spice_server_char_device_recognized_subtypes 2016-06-29 08:09:03 +01:00
spice-core.h Split spice.h 2014-11-27 14:27:18 +01:00
spice-experimental.h Add missing license headers 2015-10-19 14:25:36 +02:00
spice-input.h Split spice.h 2014-11-27 14:27:18 +01:00
spice-migration.h spice-migration.h: un-deprecate set_seamless_migration() 2016-05-12 06:34:11 +01:00
spice-qxl.h Add new spice-gl stubs API 2016-02-09 14:01:12 +00:00
spice-server.h streaming: Let the administrator pick the video encoder and codec 2016-06-14 17:04:40 +02:00
spice-server.syms streaming: Let the administrator pick the video encoder and codec 2016-06-14 17:04:40 +02:00
spice-version.h.in build-sys: generate spice-version.h 2014-11-27 14:27:33 +01:00
spice.h Split spice.h 2014-11-27 14:27:18 +01:00
spicevmc.c spicevmc_device_connect: get parser for appropriate channel_type 2016-07-14 18:44:54 +03:00
stat.h Make sure all headers are independent 2016-05-18 00:24:37 +01:00
stream.c remove CommonGraphicsChannelClient structure 2016-08-09 10:22:46 -05:00
stream.h Limit direct access to DisplayChannelClient 2016-08-09 10:22:46 -05:00
sw-canvas.c remove sw-canvas.h 2016-05-09 12:45:37 +01:00
tree.c Get code more typesafe 2016-05-21 04:14:13 +01:00
tree.h Introduce SPICE_UPCAST macro 2016-05-24 18:00:51 +01:00
utils.c worker: move dcc_add_surface_area_image 2015-11-23 13:50:44 +00:00
utils.h server: Add time constants to go with spice_get_monotonic_time_ms() 2015-12-14 11:24:47 +00:00
video-encoder.h Make video-encoder.h self independent 2016-06-16 14:14:04 +01:00
zlib-encoder.c server: rename files 2015-12-03 23:54:32 +00:00
zlib-encoder.h Make sure all headers are independent 2016-05-18 00:24:37 +01:00