Fixed bug #55131: --regexp --recstart hangs. Passes testsuite.

This commit is contained in:
Ole Tange 2018-12-02 20:18:55 +01:00
parent 1ed248a63c
commit a86ead354b
4 changed files with 68 additions and 11 deletions

View file

@ -526,10 +526,16 @@ sub spreadstdin {
# (?!negative lookahead) is needed to avoid backtracking # (?!negative lookahead) is needed to avoid backtracking
# See: https://unix.stackexchange.com/questions/439356/ # See: https://unix.stackexchange.com/questions/439356/
while($buf =~ while($buf =~
/# From start up till recend /(
^((?:(?!$recend$recstart).)*?$recend # Either recstart or at least one char from start
^(?: $recstart | .)
# followed something
(?:(?!$recend$recstart).)*?
# and then recend
$recend
# Then n-1 times recstart.*recend # Then n-1 times recstart.*recend
(?:$recstart(?:(?!$recend$recstart).)*?$recend){$read_n_lines}) (?:$recstart(?:(?!$recend$recstart).)*?$recend){$read_n_lines}
)
# Followed by recstart # Followed by recstart
(?=$recstart)/osx) { (?=$recstart)/osx) {
$anything_written += $anything_written +=
@ -1559,7 +1565,7 @@ sub check_invalid_option_combinations {
sub init_globals { sub init_globals {
# Defaults: # Defaults:
$Global::version = 20181124; $Global::version = 20181202;
$Global::progname = 'parallel'; $Global::progname = 'parallel';
$Global::infinity = 2**31; $Global::infinity = 2**31;
$Global::debug = 0; $Global::debug = 0;

View file

@ -664,7 +664,9 @@ par_X_eta_div_zero() {
# We do not care how long it took # We do not care how long it took
seq 2 | stdout parallel -X --eta echo | seq 2 | stdout parallel -X --eta echo |
grep -E -v 'ETA:.*AVG' | grep -E -v 'ETA:.*AVG' |
perl -pe 's/\d+/0/g' perl -pe 's/\d+/0/g' |
perl -pe 's/Comp.* to complete//' |
perl -ne '/../ and print'
} }
par_parcat_args_stdin() { par_parcat_args_stdin() {
@ -777,7 +779,12 @@ par_slow_pipe_regexp() {
echo "### bug #53718: --pipe --regexp -N blocks" echo "### bug #53718: --pipe --regexp -N blocks"
echo This should take a few ms, but took more than 2 hours echo This should take a few ms, but took more than 2 hours
seq 54000 80000 | seq 54000 80000 |
timeout -k 1 60 parallel -N1000 --regexp --pipe --recstart 4 --recend 5 -k wc parallel -N1000 --regexp --pipe --recstart 4 --recend 5 -k wc
echo "### These should give same output"
seq 54000 80000 |
parallel -N1000 --regexp --pipe --recstart 4 --recend 5 -k cat |
md5sum
seq 54000 80000 | md5sum
} }
par_results() { par_results() {
@ -865,7 +872,15 @@ par_space_envvar() {
export PARALLEL=" -v" && parallel echo ::: 'space in envvar OK' export PARALLEL=" -v" && parallel echo ::: 'space in envvar OK'
} }
par_pipe_N1_regexp() {
echo 'bug #55131: --regexp --recstart hangs'
echo "These should give the same"
printf 'begin\n%send\n' '' a b c |
parallel -kN1 --recstart 'begin\n' --pipe --regexp echo JOB{#}\;cat\;echo END
printf 'begin\n%send\n' '' a b c |
parallel -kN1 --recstart 'begin\n' --pipe echo JOB{#}\;cat\;echo END
}
export -f $(compgen -A function | grep par_) export -f $(compgen -A function | grep par_)
compgen -A function | grep par_ | LC_ALL=C sort | compgen -A function | grep par_ | LC_ALL=C sort |
parallel -j6 --tag -k --joblog +/tmp/jl-`basename $0` '{} 2>&1' parallel --timeout 20 -j6 --tag -k --joblog +/tmp/jl-`basename $0` '{} 2>&1'

View file

@ -1251,7 +1251,6 @@ par_PARALLEL_ENV OK as file
par_PARALLEL_ENV ### PARALLEL_ENV as fifo par_PARALLEL_ENV ### PARALLEL_ENV as fifo
par_PARALLEL_ENV OK as fifo par_PARALLEL_ENV OK as fifo
par_X_eta_div_zero ### bug #34422: parallel -X --eta crashes with div by zero par_X_eta_div_zero ### bug #34422: parallel -X --eta crashes with div by zero
par_X_eta_div_zero 0
par_X_eta_div_zero Computers / CPU cores / Max jobs to run par_X_eta_div_zero Computers / CPU cores / Max jobs to run
par_X_eta_div_zero 0:local / 0 / 0 par_X_eta_div_zero 0:local / 0 / 0
par_append_joblog ### can you append to a joblog using + par_append_joblog ### can you append to a joblog using +
@ -1391,6 +1390,40 @@ par_parcat_rm bug #51691: parcat --rm remove fifo when opened
par_parcat_rm OK1 par_parcat_rm OK1
par_parcat_rm OK file removed par_parcat_rm OK file removed
par_perlexpr_with_newline Perl expression spanning 2 lines par_perlexpr_with_newline Perl expression spanning 2 lines
par_pipe_N1_regexp bug #55131: --regexp --recstart hangs
par_pipe_N1_regexp These should give the same
par_pipe_N1_regexp JOB1
par_pipe_N1_regexp begin
par_pipe_N1_regexp end
par_pipe_N1_regexp END
par_pipe_N1_regexp JOB2
par_pipe_N1_regexp begin
par_pipe_N1_regexp aend
par_pipe_N1_regexp END
par_pipe_N1_regexp JOB3
par_pipe_N1_regexp begin
par_pipe_N1_regexp bend
par_pipe_N1_regexp END
par_pipe_N1_regexp JOB4
par_pipe_N1_regexp begin
par_pipe_N1_regexp cend
par_pipe_N1_regexp END
par_pipe_N1_regexp JOB1
par_pipe_N1_regexp begin
par_pipe_N1_regexp end
par_pipe_N1_regexp END
par_pipe_N1_regexp JOB2
par_pipe_N1_regexp begin
par_pipe_N1_regexp aend
par_pipe_N1_regexp END
par_pipe_N1_regexp JOB3
par_pipe_N1_regexp begin
par_pipe_N1_regexp bend
par_pipe_N1_regexp END
par_pipe_N1_regexp JOB4
par_pipe_N1_regexp begin
par_pipe_N1_regexp cend
par_pipe_N1_regexp END
par_pipe_no_command ### --pipe without command par_pipe_no_command ### --pipe without command
par_pipe_no_command parallel: Error: --pipe/--pipepart must have a command to pipe into (e.g. 'cat'). par_pipe_no_command parallel: Error: --pipe/--pipepart must have a command to pipe into (e.g. 'cat').
par_pipe_recend bug #54328: --pipe --recend blocks par_pipe_recend bug #54328: --pipe --recend blocks
@ -1481,8 +1514,11 @@ par_retries_replacement_string 33
par_retries_replacement_string 33 par_retries_replacement_string 33
par_slow_pipe_regexp ### bug #53718: --pipe --regexp -N blocks par_slow_pipe_regexp ### bug #53718: --pipe --regexp -N blocks
par_slow_pipe_regexp This should take a few ms, but took more than 2 hours par_slow_pipe_regexp This should take a few ms, but took more than 2 hours
par_slow_pipe_regexp 979 980 5875 par_slow_pipe_regexp 980 981 5881
par_slow_pipe_regexp 25022 25022 150131 par_slow_pipe_regexp 25021 25021 150125
par_slow_pipe_regexp ### These should give same output
par_slow_pipe_regexp 6e72d7f86f6a423b9a7fa97630587815 -
par_slow_pipe_regexp 6e72d7f86f6a423b9a7fa97630587815 -
par_space_envvar ### bug: --gnu was ignored if env var started with space: PARALLEL=' --gnu' par_space_envvar ### bug: --gnu was ignored if env var started with space: PARALLEL=' --gnu'
par_space_envvar echo 'space in envvar OK' par_space_envvar echo 'space in envvar OK'
par_space_envvar space in envvar OK par_space_envvar space in envvar OK

View file

@ -61,7 +61,7 @@ echo '### Check that 4 processes are really used'
echo '### --version must have higher priority than retired options' echo '### --version must have higher priority than retired options'
### --version must have higher priority than retired options ### --version must have higher priority than retired options
$NICEPAR --version -g -Y -U -W -T | tail $NICEPAR --version -g -Y -U -W -T | tail
GNU parallel 20181124 GNU parallel 20181202
Copyright (C) 2007-2018 Ole Tange and Free Software Foundation, Inc. Copyright (C) 2007-2018 Ole Tange and Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. This is free software: you are free to change and redistribute it.