bug#81507: [PATCH] ptx: fix infinite loop with -G and a narrow output width

Pádraig Brady <[email protected]> Tue, 28 Jul 2026 12:07:14 +0100
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
On 27/07/2026 08:03, Ayesha Shafique wrote:
> With GNU extensions disabled, before_max_width can go negative, and
> define_all_fields then loops forever trying to shrink the before field
> to a width narrower than empty:
> 
>    $ printf 'qux\n' | src/ptx -G -w2
>    [hangs]
> 
> Commit v6.12-96-g773be9eca added a clamp for this, but placed it in
> the GNU-extensions branch only.  Move it after that if/else so that
> both branches are covered.
> 
> * src/ptx.c (fix_output_parameters): Clamp before_max_width for both
> the GNU and non-GNU cases.
> * tests/ptx/ptx.pl: Add a test case.
> * NEWS: Mention the bug fix.
Very nice.

I tweaked the test to be in a different place protected by timeout(1),
and pushed.

Marking this as done.

thanks!
Padraig