Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webvtt cue with start_time == end_time not handled gracefully #335

Closed
jigneshdhruv opened this issue Mar 1, 2018 · 5 comments
Closed

Webvtt cue with start_time == end_time not handled gracefully #335

jigneshdhruv opened this issue Mar 1, 2018 · 5 comments
Assignees
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@jigneshdhruv
Copy link

We are using Shaka Packager version: 594d1f0-release

We came across a issue where shaka packager leaks memory while processing a webvtt file for HLS. We do not see this issue when processing the same webvtt with DASH.

Also this does not happen with all webvtt files.

This happened on a ubuntu server that has 64GB memory and shaka packager process took up all 64GB and then crashed.

We are trying to be very careful with our webvtt but we are worried that a bad webvtt can cause a memory leak and crash the process/server.

Here is the package command to reproduce the problem.
packager 'in=/tmp/abc.vtt,stream=text,segment_template=/tmp/output/abc/seg_$Number$.vtt,language=en,playlist_name=abc/stream_vtt.m3u8,hls_group_id=abc_vtt,hls_name=ENGLISH' --clear_lead 0 --segment_duration 6 --hls_master_playlist_output tmp/output/master.m3u8

I have send the bad webvtt file that caused memory leak to @kqyang .

Can you please take a look and let us know what is causing this memory leak?

Let us know if you need more information.

Thanks & Regards,
Jignesh

@kqyang kqyang added the type: bug Something isn't working correctly label Mar 1, 2018
@kqyang kqyang added this to the 2.1.0 milestone Mar 1, 2018
@vaage
Copy link
Contributor

vaage commented Mar 1, 2018

We have found the problem. In the DEBUG build an assert would have stopped the machine from running out of memory.

The content you have provided had two problems:

  1. There are many samples that start and end at the same time. This is not spec compliant as you can read in Section 4.1 of the WebVTT spec.
  2. There was a sample that ended at time 00:00:00.000 (which was only possible because of problem 1). This caused an overflow in the segmenting logic which tried to add the cue to all segments from 0 ms to 1.8 * 10 ^ 19 ms.

We have a fix to drop all zero-duration samples when packaging to avoid both these problems. In our fix we have added a test to ensure that this won't be re-introduced.

@jigneshdhruv
Copy link
Author

I understand that is a bad webvtt. We get these webvtt files from the publishers over whch we do not have control over that. I am glad you are applying a fix for this issue.

When will this fix be committed n the branch?

Thanks.

@vaage
Copy link
Contributor

vaage commented Mar 1, 2018

The fix is in review right now. We are hoping to get it submitted to master by end of day.

@kqyang kqyang changed the title Memory leak while processing webvtt resulting in a crash Webvtt cue with start_time == end_time not handled gracefully Mar 2, 2018
@jigneshdhruv
Copy link
Author

Thanks.

kqyang pushed a commit that referenced this issue Mar 2, 2018
We have an assert that ensures that the end time is greater than
the start time for any cue. However we never checked that cues
had a non-zero duration when parsing them.

We will throw away cues with a duration of zero (and print a
warning message) as they are not spec compliant.

Closes: #335
Change-Id: I404e8f3a5a8d43eff75a2554db3e38e8d340f421
@kqyang
Copy link
Contributor

kqyang commented Mar 3, 2018

Cherry-picked for v2.0.1.

@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label May 1, 2018
@shaka-project shaka-project locked and limited conversation to collaborators May 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

4 participants