Skip to content

Free-threaded (3.14t) data race: zlib decompress error in chunked COG sidecar read #3361

Description

@brendancol

Describe the bug

Under free-threaded Python 3.14 (3.14t), test_sidecar.py::test_fsspec_chunked_open_resolves_sidecar_overview fails with a zlib decompression error when reading a COG sidecar overview through the chunked (dask) path:

zlib.error: Error -3 while decompressing data: incorrect header check

On Windows the same test also surfaces ValueError: I/O operation on closed file.

The failure showed up on the new 3.14t CI lane (PR #3360). It reproduces on ubuntu-latest and windows-latest but not macos-latest, and never on the GIL-enabled builds (3.12, 3.13, 3.14 all pass). 9689+ other tests pass.

Likely cause

The test opens a COG with chunks=16 and then materializes .values, so tiles decompress in parallel on dask's threaded scheduler. The error pattern (corrupted zlib stream plus a closed-file error) points to a shared file handle and/or zlib decompressor used by concurrent tile reads without locking. zlib decompress objects are not thread-safe; the GIL was serializing these reads, so the race only appears once it is gone. macOS passing is consistent with a timing-dependent race rather than a platform-specific bug.

Where to look

  • xrspatial/geotiff/tests/integration/test_sidecar.py::test_fsspec_chunked_open_resolves_sidecar_overview
  • the chunked read path: xrspatial/geotiff/_backends/dask.py and the tile decode helpers it calls (_decode.py, _compression.py, _sources.py)
  • anything that holds a single open file object or a single decompressor across tiles

Notes

This is pre-existing behavior, not caused by PR #3360, which only added 3.14t to the matrix. The 3.14t job is allowed-failure, so this does not block merges; it is the signal the lane was added to provide. This issue tracks the fix toward making the free-threaded lane green.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdaskDask backend / chunked arraysgeotiffGeoTIFF module

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions