From 49f1fde635ebbe03cb6d67da23a3f45a1aa87372 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Fri, 12 Jun 2020 00:50:50 -0500 Subject: [PATCH] lac/constraints_move: Fix undefined behavior It is undefined behavior to access an object that has been moved. It is also not possible to "move back" an object. In this particular case with the recent changes to ThreadLocalStorage and AffineConstraints we run into an exception: constraints_move.debug: ../nptl/pthread_mutex_lock.c:117: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed. (The move operation destroys the mutex and accessing it afterwards when we try to move back results in a crash.) --- tests/lac/constraints_move.cc | 5 ---- tests/lac/constraints_move.output | 38 ++++++++++++------------------- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/tests/lac/constraints_move.cc b/tests/lac/constraints_move.cc index 9e62b6544a..8ff9f44cf2 100644 --- a/tests/lac/constraints_move.cc +++ b/tests/lac/constraints_move.cc @@ -39,11 +39,6 @@ main() AffineConstraints cm(std::move(constraints)); cm.print(deallog.get_file_stream()); - deallog << constraints.n_constraints() << std::endl << std::endl; - - constraints = std::move(cm); - constraints.print(deallog.get_file_stream()); - deallog << cm.n_constraints() << std::endl; deallog << "OK" << std::endl; } diff --git a/tests/lac/constraints_move.output b/tests/lac/constraints_move.output index d44670c0ec..2a4ad2699a 100644 --- a/tests/lac/constraints_move.output +++ b/tests/lac/constraints_move.output @@ -1,27 +1,17 @@ - 1 = 0.0 - 2 = 1.0 - 3 = 2.0 - 5 = 3.0 - 8 = 4.0 - 13 = 5.0 - 21 = 6.0 + 1 = 0 + 2 = 1.00000 + 3 = 2.00000 + 5 = 3.00000 + 8 = 4.00000 + 13 = 5.00000 + 21 = 6.00000 DEAL:: - 1 = 0.0 - 2 = 1.0 - 3 = 2.0 - 5 = 3.0 - 8 = 4.0 - 13 = 5.0 - 21 = 6.0 -DEAL::0 -DEAL:: - 1 = 0.0 - 2 = 1.0 - 3 = 2.0 - 5 = 3.0 - 8 = 4.0 - 13 = 5.0 - 21 = 6.0 -DEAL::0 + 1 = 0 + 2 = 1.00000 + 3 = 2.00000 + 5 = 3.00000 + 8 = 4.00000 + 13 = 5.00000 + 21 = 6.00000 DEAL::OK -- 2.39.5