Bug 156690 - REGRESSION(r198782): SHOULD NEVER BE REACHED failure in ImageSource::setData since r198782
Summary: REGRESSION(r198782): SHOULD NEVER BE REACHED failure in ImageSource::setData ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk, Regression
Depends on:
Blocks: 155322
  Show dependency treegraph
 
Reported: 2016-04-18 02:32 PDT by Carlos Garcia Campos
Modified: 2016-04-22 13:09 PDT (History)
3 users (show)

See Also:


Attachments
Patch (3.11 KB, patch)
2016-04-18 02:34 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch (2.88 KB, patch)
2016-04-19 00:56 PDT, Carlos Garcia Campos
mcatanzaro: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2016-04-18 02:32:20 PDT
The assertion is wrong, because it assumes that ImageDecoder::create() always returns a valid pointer, which is only true for the CG implementation. The non CG implementation can return nullptr if there isn't enough data to figure out the image format or if the image format is not supported. This is causing several crashes in the debug bots.
Comment 1 Carlos Garcia Campos 2016-04-18 02:34:59 PDT
Created attachment 276626 [details]
Patch
Comment 2 Simon Fraser (smfr) 2016-04-18 10:28:50 PDT
Comment on attachment 276626 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=276626&action=review

> Source/WebCore/platform/graphics/ImageSource.cpp:74
> +bool ImageSource::tryEnsureDecoderIfNeeded(const SharedBuffer& data)

"try ensure" is not a good name, and "if needed" is more like "if possible".
Comment 3 Carlos Garcia Campos 2016-04-18 23:36:44 PDT
(In reply to comment #2)
> Comment on attachment 276626 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=276626&action=review
> 
> > Source/WebCore/platform/graphics/ImageSource.cpp:74
> > +bool ImageSource::tryEnsureDecoderIfNeeded(const SharedBuffer& data)
> 
> "try ensure" is not a good name, and "if needed" is more like "if possible".

My initial idea was to use try create instead, but normally try create methods return the created object or nullptr, but this one ensures it exists. So that's why I kept the ensure part. The "if possible" is already covered by try, if needed is not because ImageDecoder::create can fail, but because there's an early return in case the decoder has already been created. I added the if needed because I initially called it try create, but I agree the ensure also covers if needed. In any case, the ensure method is only called by setData() so I wonder if we really need an ensure method after all.
Comment 4 Carlos Garcia Campos 2016-04-18 23:37:44 PDT
Btw, this is causing a lot of crashes in a our debug bot, so I would like tho fix this soon, to avoid the early exit.
Comment 5 Carlos Garcia Campos 2016-04-19 00:56:00 PDT
Created attachment 276704 [details]
Updated patch

I think the code is simpler and clearer without the ensure method. In the end we can't ensure the decoder is created.
Comment 6 Michael Catanzaro 2016-04-19 10:01:03 PDT
Comment on attachment 276704 [details]
Updated patch

Please wait one day in case Said has comments.
Comment 7 Carlos Garcia Campos 2016-04-19 23:02:17 PDT
Committed r199764: <http://trac.webkit.org/changeset/199764>