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

[Backport release-2.23] Fix segfaults in WebP queries ran in parallel. (#5065) #5121

Merged
merged 2 commits into from
Jun 19, 2024

Conversation

KiterLuc
Copy link
Contributor

Backport 47dde51 from #5065.


TYPE: BUG
DESC: Fix segfaults in WebP queries ran in parallel.

The WebpFilter calls `WriterTile::set_max_tile_chunk_size` to override
the maximum tile chunk size in an attempt to avoid further chunking data
within each tile, but because `WriterTile::max_tile_chunk_size_` is
static this doesn't work as intended when we're running multiple WebP
queries across threads. It's possible for one thread to override this
value while it's being used by another running query and this results in
incorrect chunking for WebP data, potentially causing segfaults from
libwebp reaching out of memory bounds.

The WebP library was reaching out of bounds because after another thread
overrides `max_tile_chunk_size_` we don't account for the smaller
chunk's dimensions when calling WebP APIs and still pass in the same
height, width, and row stride to [WebP API
calls](https://github.com/TileDB-Inc/TileDB/blob/dev/tiledb/sm/filter/webp_filter.cc#L144).

This PR removes the use of `WriterTile::set_max_tile_chunk_size` and
updates `FilterPipeline::use_tile_chunking` to return `false` for WebP,
which IIUC should have the behavior that was initially intended and
fixes segfaults seen on REST.


[SC-48697](https://app.shortcut.com/tiledb-inc/story/48697/rest-segfaults-running-webp-multiple-queries)

Limitations: If a WebP array exists that was impacted by this during
ingestion and it did not produce a segfault, that array will still be
read back using chunking. AFAICT there is no risk of segfault for this
case since the decoding APIs in WebP do not depend on the caller to
specify buffer dimensions, instead WebP will decode and provides to the
caller the width and height of the decoded image. On the next write to
the array there will be no error or risk of segfault and the new tiles
will not use chunking moving forward for reads or writes.

---
TYPE: BUG
DESC: Fix segfaults in WebP queries ran in parallel.
@KiterLuc KiterLuc requested a review from teo-tsirpanis June 19, 2024 16:52
@KiterLuc KiterLuc merged commit 2c19a17 into release-2.23 Jun 19, 2024
58 of 59 checks passed
@KiterLuc KiterLuc deleted the backport-5065-to-release-2.23 branch June 19, 2024 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants