summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-01-22 08:52:55 +0100
committerAndras Timar <andras.timar@collabora.com>2020-02-12 16:27:26 +0100
commitfbe3458aa492df7786eaefeb5e782e2d894d9613 (patch)
tree5b3f14369cf6789b06ebd3edd826f3a4673bb946
parentd33a1cc476cf8790b018d88b8c0333062e4157c6 (diff)
Fix an UB in the DocumentBroker dtor
The problem is that both the DocBrokers map and the instance returned by Admin::instance() are static, so there it's not safe to assume that by the time the DocumentBroker dtor runs, the static Admin instance is still alive. Still, the DocumentBroker dtor calls Admin::instance(). Fix this by clearing the DocBrokers map in LOOLWSD::cleanup(), which is used exactly to destroy statics in a controlled order. Sanitizers output was: wsd/DocumentBroker.cpp:497:23: runtime error: member call on address 0x0000024a5ba0 which does not point to an object of type 'Admin' 0x0000024a5ba0: note: object is of type 'SocketPoll' 00 00 00 00 50 21 45 01 00 00 00 00 b8 5b 4a 02 00 00 00 00 05 00 00 00 00 00 00 00 61 64 6d 69 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'SocketPoll' #0 0xa10af3 in DocumentBroker::~DocumentBroker() wsd/DocumentBroker.cpp:497:23 ... #17 0x7fa27622ddc9 in exit (/lib64/libc.so.6+0x38dc9) #18 0x7fa276215f90 in __libc_start_main (/lib64/libc.so.6+0x20f90) #19 0x670189 in _start /home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:120 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior wsd/DocumentBroker.cpp:497:23 in (Seen during make check CPPUNIT_TEST_NAME="unit-each-view".) Conflicts: wsd/LOOLWSD.cpp Change-Id: I02ad44deb9de06d9973216428c640248ea2512ce Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87178 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--.gitreview2
-rw-r--r--wsd/LOOLWSD.cpp4
2 files changed, 5 insertions, 1 deletions
diff --git a/.gitreview b/.gitreview
index 489239f60..402f38775 100644
--- a/.gitreview
+++ b/.gitreview
@@ -3,5 +3,5 @@ host=logerrit
port=29418
project=online
defaultremote=logerrit
-defaultbranch=distro/collabora/collabora-online-4
+defaultbranch=distro/collabora/collabora-online-4-0
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 97b774cd0..44d43ae35 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3392,6 +3392,10 @@ void LOOLWSD::cleanup()
}
#endif
#endif
+
+ // Delete these while the static Admin instance is still alive.
+ std::lock_guard<std::mutex> docBrokersLock(DocBrokersMutex);
+ DocBrokers.clear();
}
int LOOLWSD::main(const std::vector<std::string>& /*args*/)