From: Matthias Maier Date: Fri, 12 Jun 2020 05:50:50 +0000 (-0500) Subject: lac/constraints_move: Fix undefined behavior X-Git-Tag: v9.3.0-rc1~1441^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F10519%2Fhead;p=dealii.git 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.) --- 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