Skip to content

Add range check min_gf_interval in validate_config - #5298

Merged
urvangjoshi merged 1 commit into
AOMediaCodec:mainfrom
xinzhao-apple:mr/avm-bugfix2
Aug 20, 2026
Merged

Add range check min_gf_interval in validate_config#5298
urvangjoshi merged 1 commit into
AOMediaCodec:mainfrom
xinzhao-apple:mr/avm-bugfix2

Conversation

@xinzhao-apple

Copy link
Copy Markdown
Contributor

--min-gf-interval=1..3 bypasses the clamp the auto path applies, which defeats the baseline_gf_interval < min_gf_interval guard in define_gf_group(). A degenerate end-of-sequence group then builds an ARF whose temporal filter reads past the end of the lookahead and segfaults.

Valid configurations are bit-identical; 1..3 now match min=4.

This resolves issue #5297.

@urvangjoshi

Copy link
Copy Markdown
Contributor

@xinzhao-apple : Good catch!

However, I see that for max_gf_interval, we have a range check here itself: https://github.com/AOMediaCodec/avm/blob/main/av2/av2_cx_iface.c#L698

It seems best to do the same for min_gf_interval also.

@xinzhao-apple xinzhao-apple changed the title Clamp user-specified min_gf_interval to MIN_GF_INTERVAL Add range check min_gf_interval in validate_config Aug 20, 2026
@xinzhao-apple

Copy link
Copy Markdown
Contributor Author

@xinzhao-apple : Good catch!

However, I see that for max_gf_interval, we have a range check here itself: https://github.com/AOMediaCodec/avm/blob/main/av2/av2_cx_iface.c#L698

It seems best to do the same for min_gf_interval also.

@urvangjoshi , I agree, the commit has been amended, please take a look. Thanks!

--min-gf-interval=1..3 was accepted, bypassing the clamp to
MIN_GF_INTERVAL (4) that the auto path applies. That defeats the
baseline_gf_interval < min_gf_interval guard in define_gf_group()
(pass2_strategy.c), and a degenerate end-of-sequence group then builds
an ARF whose temporal filter reads past the end of the lookahead:
av2_lookahead_peek() returns NULL behind an assert compiled out under
NDEBUG, faulting in tf_setup_filtering_buffer().

Add a lower bound for min_gf_interval, mirroring the check already
present for max_gf_interval. The max_gf_interval floor also has to move
from 2 to MIN_GF_INTERVAL: with min unset it admitted
--max-gf-interval=2, which the trailing AVMMIN(min, max) in
av2_rc_set_gf_interval_range() then propagated into min_gf_interval,
reaching the same crash by a second route.

Values below MIN_GF_INTERVAL are now rejected with
AVM_CODEC_INVALID_PARAM rather than silently clamped, so a caller is
told its request was not honoured. Valid configurations are unaffected
and bit-identical.
@urvangjoshi
urvangjoshi merged commit 21ad150 into AOMediaCodec:main Aug 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants