On Tue, Feb 11, 2020 at 08:36:43AM +1300, Olly Betts wrote:
> I've noticed this message repeatedly appearing in the ci.debian.net logs:
>
> Can't "next" outside a loop block at /usr/bin/abi-compliance-checker line
> 10171.
>
> That's the "next" in this function:
>
> sub exec_helper(@)
> {
> my ($reader, $writer) = @_;
> do {
> chomp($line = <$reader>);
> next if (!$line);
> if ($line eq 'exit') {
> exit(0);
> }
> system($line);
> print $writer "$? $!\n";
> } while(1);
> }
>
> This is a quirk of Perl - "next" doesn't work in a "do { ... } while"
> like "continue" in C/C++ does because it's really a "do { ... }" block
> with a while applied.
>
> "perldoc perlsyn" suggests just doubling the braces on the loop, but in
> this case a clearer fix (untested) is probably to rewrite the loop in
> the form: "while(1) { ... }"
>
> The actual current effect of "next" here seems to be to terminate the
> loop. That seems problematic on the face of it, but in practice I
> think the only cases where it would trigger are an entirely empty line or
> "0" with no newline, both of which would mean the end of the input
> stream.
Oh, except that there's a chomp() first, so it seems we'll exit early
if we read a blank line or a line containing only "0". I guess those
are unlikely as this seems to be reading commands to execute.
> But maybe the loop should terminate at the end of the input stream,
> since otherwise it seems this loop will never terminate if the stream
> ends without "exit" being received. So perhaps the better fix is:
>
> if (!$line || $line eq 'exit') {
> exit(0);
> }
So this won't work as-is.
The problematic code is from a patch we're applying:
https://sources.debian.org/src/abi-compliance-checker/2.3-0.2/debian/patches/oom-exec-helper.patch/
Cc-ing Steve Langasek as the author of that patch.
Cheers,
Olly