diff --git a/Jenkinsfile b/Jenkinsfile index 22592d3fc..4eb17ae5c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { environment { CONAN_USER_HOME_SHORT = 'None' OSP_CONAN_CREDS = credentials('jenkins-osp-conan-creds') - CSE_CONAN_CHANNEL = "${env.BRANCH_NAME}".replaceAll("/", "_") + CSE_CONAN_CHANNEL = "${env.BRANCH_NAME}".take(51).replaceAll("/", "_") } options { checkoutToSubdirectory('cse-core') } @@ -15,7 +15,7 @@ pipeline { parallel { stage('Build on Windows') { agent { label 'windows' } - + environment { CONAN_USER_HOME = "${env.SLAVE_HOME}/conan-repositories/${env.EXECUTOR_NUMBER}" } @@ -93,7 +93,7 @@ pipeline { success { dir('release-build') { sh "conan export-pkg ../cse-core osp/${CSE_CONAN_CHANNEL} -pf package/windows/release --force" - sh "conan upload cse-core/*@osp/${CSE_CONAN_CHANNEL} --all -r=osp --confirm" + sh "conan upload cse-core/*@osp/${CSE_CONAN_CHANNEL} --all -r=osp --confirm" } dir('release-build/package') { archiveArtifacts artifacts: '**', fingerprint: true @@ -166,7 +166,7 @@ pipeline { } } stage ( 'Build on Linux with Conan' ) { - agent { + agent { dockerfile { filename 'Dockerfile.conan-build' dir 'cse-core/.dockerfiles' @@ -178,7 +178,7 @@ pipeline { environment { CONAN_USER_HOME = '/conan_repo' } - + stages { stage('Configure Conan') { steps { @@ -332,8 +332,8 @@ pipeline { } } stage ( 'Build on Linux with Docker' ) { - agent { - dockerfile { + agent { + dockerfile { filename 'Dockerfile.build' dir 'cse-core/.dockerfiles' label 'linux && docker' diff --git a/src/cpp/algorithm.cpp b/src/cpp/algorithm.cpp index 94181f5a9..51320dac7 100644 --- a/src/cpp/algorithm.cpp +++ b/src/cpp/algorithm.cpp @@ -75,12 +75,12 @@ class fixed_step_algorithm::impl void disconnect_variable(variable_id input) { for (auto& s : simulators_) { - auto conns = s.second.outgoingConnections; + auto& conns = s.second.outgoingConnections; const auto it = std::find_if( conns.begin(), conns.end(), [input](const auto& c) { return c.input == input; }); - conns.erase(it); + if (it != conns.end()) conns.erase(it); } } diff --git a/test/cpp/fixed_step_algorithm_test.cpp b/test/cpp/fixed_step_algorithm_test.cpp index eb79455cd..d03ecf8e4 100644 --- a/test/cpp/fixed_step_algorithm_test.cpp +++ b/test/cpp/fixed_step_algorithm_test.cpp @@ -53,6 +53,12 @@ int main() } } + // Test for issue #284, "fixed_step_algorithm crashes when a variable is reconnected". + // The following statement should be a no-op. + execution.connect_variables( + cse::variable_id{0, cse::variable_type::real, realOutIndex}, + cse::variable_id{1, cse::variable_type::real, realInIndex}); + auto observer2 = std::make_shared(); execution.add_observer(observer2); observer2->start_observing(cse::variable_id{9, cse::variable_type::real, realOutIndex});