Repository navigation
Conversation
* read and write callbacks that raise now return -1 instead of 0, so libvips sees an error rather than EOF or a zero-length write, and the exception is printed to stderr rather than stdout * SourceCustom#on_read used `return` inside a block, which raised LocalJumpError at EOF (printing "read: unexpected return") * SourceCustom#on_read called #clear on the returned chunk, which raised on frozen strings * SourceCustom#on_read wrote past the buffer when the block returned more bytes than requested
Member
|
Please do not use LLMs to generate code or PR descriptions when contributing to libvips: EvidenceThe 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a few problems with custom sources and targets that I ran into while adding IO streaming to ImageProcessing.
Callback exceptions were treated as EOF. When an
on_readoron_writeblock raised,MARSHAL_READ/MARSHAL_WRITEprinted the exception to stdout and returned 0. For reads, libvips took that as EOF. For a network IO that failed partway, the result was a silently truncated image. The callbacks now return -1, so libvips sees a read or write error.With this, a failed read makes WebP, TIFF, HEIF and GIF loads fail. Before, GIF was silently truncated, and the others failed with an unrelated message. The JPEG and PNG loaders still treat a failed read as a truncated file, which is only a warning unless
fail_on: :truncatedis set. Should libvips treat a source read error as a hard error regardless offail_on? An I/O error isn't the same as a truncated file.I first tried adding the exception message to the libvips error buffer, so that
Vips::Errorwould include it. But when the JPEG or PNG loader swallows the error, the message stays in the buffer and ends up in the next unrelatedVips::Error, so I left that out.Callback exceptions are printed with
warninstead ofputs. The message is a diagnostic, so it belongs on stderr: stdout may be carrying the image itself, e.g. when writing to a target on fd 1, and the message would end up in the middle of that data.warnalso goes throughWarning.warn, so apps can send it to their logger. The trade-off is that it's silenced when$VERBOSEisnil.SourceCustom#on_readfixes:return 0 if chunk.nil?inside thesignal_connectblock, which raisedLocalJumpErrorat every EOF. It was caught and printed asread: unexpected return(seen in Random segfaults, lockups @ high CPU usage, and "read: unexpected return" messages #384). Changed tonext 0.chunk.clearon the returned string, which raisesFrozenErrorfor frozen strings. Before this change, that error was then treated as EOF. Frozen strings are now left alone.lengthbytes overflowed the buffer. On master this crashes the process withGLib-ERROR: adding 4097 to array would overflow. It now raises, which is reported as a read error.🤖 Generated with Claude Code