fix: strip null bytes from GCC output and handle empty YAML files#1
Open
MrChocolateMoose wants to merge 2 commits into
Open
fix: strip null bytes from GCC output and handle empty YAML files#1MrChocolateMoose wants to merge 2 commits into
MrChocolateMoose wants to merge 2 commits into
Conversation
Three bugs addressed that were previously worked around via a runtime
monkey patch (RUBYOPT=-r ceedling_fix.rb):
1. SystemWrapper#shell_capture3: Strip null bytes from stdout/stderr
captured via Open3.capture3. GCC -H and -E can inject null bytes
that cause ArgumentError ('string contains null byte') in
downstream file path operations and YAML parsing.
2. YamlWrapper#load: Return [] instead of false for empty YAML files.
YAML.load('') returns false in Ruby; callers check .nil? || .empty?
which raises NoMethodError on false.
3. PreprocessinatorExtractor#extract_file_as_array_from_expansion:
Strip null bytes from GCC -E preprocessed output before line-by-line
processing. Stale or freshly-generated expansion files may contain
embedded nulls that break encoding operations.
gavin-dunlap-luminar
approved these changes
Mar 16, 2026
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.
Problem
When GCC
-Hor-Eoutput contains embedded null bytes (common with certain toolchains and build configurations), Ceedling hitsArgumentError: string contains null byteduring file path operations or YAML parsing. Separately, empty YAML files produced during preprocessing causeNoMethodErrorbecauseYAML.load("")returnsfalse, and downstream code calls.empty?on it.These issues were worked around externally via a monkey patch loaded through
RUBYOPT. This PR applies the fixes at the source.Changes
SystemWrapper#shell_capture3— strip null bytes from captured stdout/stderr before freezing and returning. Prevents the null byteArgumentErrorfrom propagating into tool executor output handling, file operations, and YAML parsing.YamlWrapper#load— return[]instead offalsewhenYAML.loadgets an empty source string. In Ruby,YAML.load("")returnsfalserather thannilor[], which breaks callers that doresult.nil? || result.empty?.PreprocessinatorExtractor#extract_file_as_array_from_expansion— read the full IO content and strip null bytes before the line-by-line extraction loop. GCC-Eexpansion files can contain embedded nulls that corrupt encoding during iteration.