Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #284, "fixed_step_algorithm crashes when a variable is reconnected" #285

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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') }
Expand All @@ -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}"
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -166,7 +166,7 @@ pipeline {
}
}
stage ( 'Build on Linux with Conan' ) {
agent {
agent {
dockerfile {
filename 'Dockerfile.conan-build'
dir 'cse-core/.dockerfiles'
Expand All @@ -178,7 +178,7 @@ pipeline {
environment {
CONAN_USER_HOME = '/conan_repo'
}

stages {
stage('Configure Conan') {
steps {
Expand Down Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
6 changes: 6 additions & 0 deletions test/cpp/fixed_step_algorithm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<cse::time_series_observer>();
execution.add_observer(observer2);
observer2->start_observing(cse::variable_id{9, cse::variable_type::real, realOutIndex});
Expand Down