From b4a484bd8bc7a9118793d3ad8abb3de161006738 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20MOTTELET?= Date: Thu, 16 May 2019 19:09:12 +0200 Subject: [PATCH 1/1] * Bug 15374 fixed: now trivial infinite loop can be interrupted http://bugzilla.scilab.org/show_bug.cgi?id=15374 Change-Id: I29f265bb156d0f956bc5ef1837b0419bd4119eb4 --- scilab/CHANGES.md | 1 + scilab/modules/ast/src/cpp/ast/run_SeqExp.hpp | 31 ++++++++++++++++++++ .../modules/ast/tests/nonreg_tests/bug_15374.tst | 23 +++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 scilab/modules/ast/tests/nonreg_tests/bug_15374.tst diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index d50b731..e4fbfb7 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -210,6 +210,7 @@ Bug Fixes * [#15715](http://bugzilla.scilab.org/show_bug.cgi?id=15715): `%nan` indices crashed Scilab. * [#15581](http://bugzilla.scilab.org/show_bug.cgi?id=15581): display of complex matrix was ugly. * [#15680](http://bugzilla.scilab.org/show_bug.cgi?id=15680): `loadmatfile()` could not return variables in a structure instead of into the calling environment. +* [#15734](http://bugzilla.scilab.org/show_bug.cgi?id=15734): Trivial infinite loop could not be interrupted. * [#15744](http://bugzilla.scilab.org/show_bug.cgi?id=15744): `sylm(a,b)` yielded an error when degree(a)==0 or degree(b)==0. * [#15745](http://bugzilla.scilab.org/show_bug.cgi?id=15745): `diophant(0,0,m)`, `diophant([p 0],q)`, `diophant([0 p],q)` with m<>0 and p>q were wrong. There was no flag for cases with an infinite number of solutions. When there is no solution, some values were returned anyway, instead of []. In this case, the documented definition of the err value was dubious. Decimal numbers and integers were accepted, but not encoded integers. Inf and NaN input coefficients were not rejected. * [#15812](http://bugzilla.scilab.org/show_bug.cgi?id=15812): On assigning variables the source variable may become become corrupted diff --git a/scilab/modules/ast/src/cpp/ast/run_SeqExp.hpp b/scilab/modules/ast/src/cpp/ast/run_SeqExp.hpp index e9160e7..9b1e9e9 100644 --- a/scilab/modules/ast/src/cpp/ast/run_SeqExp.hpp +++ b/scilab/modules/ast/src/cpp/ast/run_SeqExp.hpp @@ -48,6 +48,37 @@ void RunVisitorT::visitprivate(const SeqExp &e) } } + if (exps.size() == 0) + { + if (ConfigVariable::isExecutionBreak()) + { + ConfigVariable::resetExecutionBreak(); + if (ConfigVariable::isPrintInteractive()) + { + ClearTemporaryPrompt(); + } + + StorePrioritaryCommand("pause"); + ThreadManagement::WaitForRunMeSignal(); + } + + // interrupt me to execute a prioritary command + while (StaticRunner_isInterruptibleCommand() == 1 && StaticRunner_isRunnerAvailable() == 1) + { + StaticRunner_launch(); + StaticRunner_setInterruptibleCommand(1); + } + + if (file) + { + file->close(); + delete file; + } + + CoverageInstance::stopChrono((void*)&e); + return; + } + for (; it != itEnd; ++it) { if (ConfigVariable::isExecutionBreak()) diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_15374.tst b/scilab/modules/ast/tests/nonreg_tests/bug_15374.tst new file mode 100644 index 0000000..212d8a6 --- /dev/null +++ b/scilab/modules/ast/tests/nonreg_tests/bug_15374.tst @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2019 - Stéphane MOTTELET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// <-- NO CHECK REF --> +// <-- INTERACTIVE TEST --> +// +// <-- Non-regression test for bug 15374 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/15374 +// +// <-- Short Description --> +// Trivial infinite loop cannot be interrupted + +// following loop should be interruptible by CTRL-C on the command line, +// Control/Interrupt and Control/Abort menu items + +while 1;end \ No newline at end of file -- 1.7.9.5