Skip to content

Release the GVL during Region#fetch - #447

Closed
janko wants to merge 1 commit into
libvips:masterfrom
janko:region-fetch-gvl
Closed

janko wants to merge 1 commit into
libvips:masterfrom
janko:region-fetch-gvl

Conversation

@janko

@janko janko commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

vips_region_fetch evaluates the pipeline just like copy_memory and write_to_memory, so this attaches it with blocking: true as well, following #446.

Besides stalling other Ruby threads, holding the GVL here can deadlock the process when the image comes from a Vips::SourceCustom. libvips calls the read callback from a worker thread, and that callback needs the GVL, which the thread inside fetch is holding. This came up while adding IO streaming to ImageProcessing, which loads images from a SourceCustom. There, calling write_to_memory on ruby-vips 2.3.0 deadlocked the process. #446 fixes that on master, and fetch is the remaining call that evaluates the pipeline while holding the GVL.

🤖 Generated with Claude Code

vips_region_fetch evaluates the pipeline just like copy_memory and
write_to_memory, so other Ruby threads stall until it returns. With a
SourceCustom image it deadlocks, as libvips calls the read callback from a
worker thread, which needs the GVL held by the thread in fetch.
@kleisauke

Copy link
Copy Markdown
Member

Please do not use LLMs to generate code or PR descriptions when contributing to libvips:
https://github.com/libvips/libvips/blob/master/CONTRIBUTING.md#ai-policy

Evidence

The GitHub audit log indicate that the contribution was made using Claude Code:

user_agent	GitHub CLI 2.95.0 Agent/claude-code_2-1-330_agent

@kleisauke

Copy link
Copy Markdown
Member

I made a quick non-LLM PR here: #449. Thank you for reporting this @janko, I credited you in the changelog.

@janko

janko commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @kleisauke!

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.

2 participants