[Libreoffice-commits] core.git: sal/cppunittester sal/Executable_cppunittester.mk

2021-07-28 Thread Noel Grandin (via logerrit)
 sal/Executable_cppunittester.mk |6 
 sal/cppunittester/cppunittester.cxx |  284 +---
 2 files changed, 211 insertions(+), 79 deletions(-)

New commits:
commit 24b06b9c6bdb777dff385b0fbfc81d55d3d013a1
Author: Noel Grandin 
AuthorDate: Tue Jul 27 15:15:21 2021 +0200
Commit: Noel Grandin 
CommitDate: Wed Jul 28 18:34:08 2021 +0200

log access violation on windows tinderboxen

where we currently have no good feedback when something
goes wrong.

Credit: Exception printing code written by
  msdn-whiteknight
as seen at
  
https://stackoverflow.com/questions/22467604/how-can-you-use-capturestackbacktrace-to-capture-the-exception-stack-not-the-ca

Change-Id: I44c65b10c0b0151c3236521d62a824570d4cdccf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119561
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sal/Executable_cppunittester.mk b/sal/Executable_cppunittester.mk
index 3b9016783b80..959b3cd8be47 100644
--- a/sal/Executable_cppunittester.mk
+++ b/sal/Executable_cppunittester.mk
@@ -28,6 +28,12 @@ $(eval $(call 
gb_Executable_add_exception_objects,cppunittester,\
sal/cppunittester/cppunittester \
 ))
 
+ifneq ($(strip $(debug)$(DEBUG)),)
+$(eval $(call gb_Executable_use_system_win32_libs,cppunittester,\
+   dbghelp \
+))
+endif
+
 ifeq ($(COM),MSC)
 
 $(eval $(call gb_Executable_add_ldflags,cppunittester,\
diff --git a/sal/cppunittester/cppunittester.cxx 
b/sal/cppunittester/cppunittester.cxx
index 7ab54da02106..c899f320ad0c 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -23,6 +23,9 @@
 #endif
 #include 
 #endif
+#if defined(_WIN32) && defined(_DEBUG)
+#include "dbghelp.h"
+#endif
 
 #ifdef UNX
 #include 
@@ -378,109 +381,232 @@ void reportResourceUsage([[maybe_unused]] const 
OUString& /*rPath*/)
 
 }
 
-SAL_IMPLEMENT_MAIN()
+static bool main2()
 {
 bool ok = false;
 OUString path;
-try
-{
+
 #ifdef _WIN32
-//Disable Dr-Watson in order to crash simply without popup dialogs 
under
-//windows
-DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
-SetErrorMode(SEM_NOGPFAULTERRORBOX|dwMode);
+//Disable Dr-Watson in order to crash simply without popup dialogs under
+//windows
+DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
+SetErrorMode(SEM_NOGPFAULTERRORBOX|dwMode);
 #ifdef _DEBUG // These functions are present only in the debugging runtime
-_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
-_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
-_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
-_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
-_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
-_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
+_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
+_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
+_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
 #endif
 #endif
 
-std::vector protectors;
-CppUnit::TestResult result;
-std::string args;
-std::string testlib;
-sal_uInt32 index = 0;
-while (index < osl_getCommandArgCount())
+std::vector protectors;
+CppUnit::TestResult result;
+std::string args;
+std::string testlib;
+sal_uInt32 index = 0;
+while (index < osl_getCommandArgCount())
+{
+OUString arg = getArgument(index);
+if (arg.startsWith("-env:CPPUNITTESTTARGET=", ))
 {
-OUString arg = getArgument(index);
-if (arg.startsWith("-env:CPPUNITTESTTARGET=", ))
-{
-++index;
-continue;
-}
-if (arg.startsWith("-env:"))
+++index;
+continue;
+}
+if (arg.startsWith("-env:"))
+{
+++index;
+continue; // ignore it here - will be read later
+}
+if ( arg != "--protector" )
+{
+if (testlib.empty())
 {
-++index;
-continue; // ignore it here - will be read later
+testlib = OUStringToOString(arg, 
osl_getThreadTextEncoding()).getStr();
+args += testlib;
 }
-if ( arg != "--protector" )
+else
 {
-if (testlib.empty())
-{
-testlib = OUStringToOString(arg, 
osl_getThreadTextEncoding()).getStr();
-args += testlib;
-}
-else
-{
-args += ' ';
-

[Libreoffice-commits] core.git: sal/cppunittester sal/Executable_cppunittester.mk

2020-05-24 Thread Mike Kaganski (via logerrit)
 sal/Executable_cppunittester.mk |4 
 sal/cppunittester/cppunittester.cxx |   10 --
 2 files changed, 4 insertions(+), 10 deletions(-)

New commits:
commit b3c8859cd20bd02adea5d2b026001f67feacc754
Author: Mike Kaganski 
AuthorDate: Sun May 24 11:42:02 2020 +0200
Commit: Mike Kaganski 
CommitDate: Sun May 24 12:30:32 2020 +0200

Revert "Try to blind-solve cppunittester hangs on Windows"

This reverts commit 1126515226b60630b3a0fd72c45258b230dfe8fd.

Reason for revert: it only took one run after merging the patch to see it
still hangs...

Change-Id: I9235004d0568462b112da7f23bc615f3647f4755
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94677
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sal/Executable_cppunittester.mk b/sal/Executable_cppunittester.mk
index 65426e722240..3b9016783b80 100644
--- a/sal/Executable_cppunittester.mk
+++ b/sal/Executable_cppunittester.mk
@@ -28,10 +28,6 @@ $(eval $(call 
gb_Executable_add_exception_objects,cppunittester,\
sal/cppunittester/cppunittester \
 ))
 
-$(eval $(call gb_Executable_use_system_win32_libs,cppunittester,\
-   ole32 \
-))
-
 ifeq ($(COM),MSC)
 
 $(eval $(call gb_Executable_add_ldflags,cppunittester,\
diff --git a/sal/cppunittester/cppunittester.cxx 
b/sal/cppunittester/cppunittester.cxx
index 1b3c518c4b21..a760ecf8ff41 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -18,9 +18,10 @@
  */
 
 #ifdef _WIN32
-#include 
-#include 
-#include 
+#if !defined WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+#include 
 #endif
 
 #ifdef UNX
@@ -388,9 +389,6 @@ SAL_IMPLEMENT_MAIN()
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
 #endif
-
-// Tests may use e.g. OLE or clipboard; initialize COM and appropriate 
concurrency early
-OleInitialize(nullptr);
 #endif
 
 std::vector protectors;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sal/cppunittester sal/Executable_cppunittester.mk

2020-05-24 Thread Mike Kaganski (via logerrit)
 sal/Executable_cppunittester.mk |4 
 sal/cppunittester/cppunittester.cxx |   10 ++
 2 files changed, 10 insertions(+), 4 deletions(-)

New commits:
commit 1126515226b60630b3a0fd72c45258b230dfe8fd
Author: Mike Kaganski 
AuthorDate: Sun May 24 09:18:10 2020 +0200
Commit: Mike Kaganski 
CommitDate: Sun May 24 10:28:59 2020 +0200

Try to blind-solve cppunittester hangs on Windows

... calling OleInitialize early in sal_main to initialize COM and 
concurrency.

Seeing intermittent hangs in main thread in CAPNDataObject::GetData calling
m_rIDataObjectOrg->GetData, and the inner stack waiting objects in the code
doing apartment switching (I forgot to save a stack to paste unfortunately),
I suspect that being related to incorrect concurrency model. OleInitialize
docs [1] mention:

  Applications that use the following functionality must call OleInitialize
  before calling any other function in the COM library:

  * Clipboard
  * Drag and Drop
  * Object linking and embedding (OLE)
  * In-place activation

  ...

  Because OLE operations are not thread-safe, OleInitialize specifies the
  concurrency model as single-thread apartment.

CoInitializeEx sets COINIT_MULTITHREADED by default, so possibly that might
get called somewhere before clipboard/OLE code is called. I hope that this
change would fix those hangs.

[1] 
https://docs.microsoft.com/en-us/windows/win32/api/ole2/nf-ole2-oleinitialize

Change-Id: I7213c9d6cb4bd0691a3ce355995157797d7db93f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94675
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sal/Executable_cppunittester.mk b/sal/Executable_cppunittester.mk
index 3b9016783b80..65426e722240 100644
--- a/sal/Executable_cppunittester.mk
+++ b/sal/Executable_cppunittester.mk
@@ -28,6 +28,10 @@ $(eval $(call 
gb_Executable_add_exception_objects,cppunittester,\
sal/cppunittester/cppunittester \
 ))
 
+$(eval $(call gb_Executable_use_system_win32_libs,cppunittester,\
+   ole32 \
+))
+
 ifeq ($(COM),MSC)
 
 $(eval $(call gb_Executable_add_ldflags,cppunittester,\
diff --git a/sal/cppunittester/cppunittester.cxx 
b/sal/cppunittester/cppunittester.cxx
index a760ecf8ff41..1b3c518c4b21 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -18,10 +18,9 @@
  */
 
 #ifdef _WIN32
-#if !defined WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-#endif
-#include 
+#include 
+#include 
+#include 
 #endif
 
 #ifdef UNX
@@ -389,6 +388,9 @@ SAL_IMPLEMENT_MAIN()
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
 #endif
+
+// Tests may use e.g. OLE or clipboard; initialize COM and appropriate 
concurrency early
+OleInitialize(nullptr);
 #endif
 
 std::vector protectors;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits