office-gobmx/external/coinmp/odr.patch
Stephan Bergmann 0408e5344b external/coinmap: Address ODR violations
...since 2193650b33 "external/coinmp: Update to
CoinMP 1.8.4", as reported by <https://ci.libreoffice.org/job/lo_ubsan/2805/>,

> ==25531==ERROR: AddressSanitizer: odr-violation (0x7f3df9756e40):
>   [1] size=4 'CbcOrClpEnvironmentIndex' /home/tdf/lode/jenkins/workspace/lo_ubsan/workdir/UnpackedTarball/coinmp/Clp/src/CbcOrClpParam.cpp:1236:5
>   [2] size=4 'CbcOrClpEnvironmentIndex' CbcOrClpParam.cpp:1236:5
> These globals were registered at these points:
>   [1]:
>     #0 0x43e508 in __asan_register_globals.part.13 /home/tdf/lode/packages/llvm-llvmorg-12.0.1.src/compiler-rt/lib/asan/asan_globals.cpp:360
>     #1 0x7f3df9252a6b in asan.module_ctor (/instdir/program/libCbcSolver.so.3+0x21fa6b)
> LLVMSymbolizer: error reading file: No such file or directory
>     #2 0x7ffda20d8279  ([stack]+0x32279)
>
>   [2]:
>     #0 0x43e508 in __asan_register_globals.part.13 /home/tdf/lode/packages/llvm-llvmorg-12.0.1.src/compiler-rt/lib/asan/asan_globals.cpp:360
>     #1 0x7f3df4973a4b in asan.module_ctor (/instdir/program/libClpSolver.so.1+0x127a4b)
>     #2 0x7ffda20d8279  ([stack]+0x32279)

and similarly for CbcOrClpRead_mode and CbcOrClpReadCommand.

There's code using those three extern variables in both libCbcSolver.so.3 and
libClpSolver.so.1, and some of it is duplicated (in
workdir/UnpackedTarball/coinmp/Clp/src/CbcOrClpParam.cpp, which is also included
from workdir/UnpackedTarball/coinmp/Cbc/src/CbcCbcParam.cpp).  Those libraries
do not appear to make any use of symbol visibility hiding, and it is completely
unclear to me how all that code is actually meant to work.  But it also smells
like all that code is only used within standalone programs (see main in
workdir/UnpackedTarball/coinmp/Cbc/src/CoinSolve.cpp and
workdir/UnpackedTarball/coinmp/Clp/src/ClpMain.cpp).  So lets try to get away
with properly sharing those three extern variables across those two libraries.
Except on Windows, where linking the one library wouldn't find the extern
variables from the other library (and I'm not sure whether that's a general
issue on Windows, or is due to how 2193650b33
modified external/coinmp/windows.build.patch.1).

(This also appears to be fixed on recent upstream;
<https://github.com/coin-or/Cbc> no longer mentions any of those three extern
variables.  Maybe a new tarball will eventually appear at
<http://www.coin-or.org/download/source/CoinMP/> that includes a proper fix of
these ODR violations.)

Change-Id: I953c7dc31f8e35315c59dc2bedd3fdf780579638
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153001
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-06-14 07:24:36 +02:00

30 lines
753 B
Diff

--- Cbc/src/CbcSolver.cpp
+++ Cbc/src/CbcSolver.cpp
@@ -970,8 +970,13 @@
this set of calls thread-safe.
*/
+#if defined _MSC_VER
int CbcOrClpRead_mode = 1;
FILE * CbcOrClpReadCommand = stdin;
+#else
+extern int CbcOrClpRead_mode;
+extern FILE * CbcOrClpReadCommand;
+#endif
extern int CbcOrClpEnvironmentIndex;
int callCbc1(const char * input2, CbcModel & model,
--- Clp/src/CbcOrClpParam.cpp
+++ Clp/src/CbcOrClpParam.cpp
@@ -1233,7 +1233,11 @@
static char line[1000];
static char * where = NULL;
extern int CbcOrClpRead_mode;
+#if defined _MSC_VER || !defined COIN_HAS_CBC
int CbcOrClpEnvironmentIndex = -1;
+#else
+extern int CbcOrClpEnvironmentIndex;
+#endif
static size_t fillEnv()
{
#if defined(_MSC_VER) || defined(__MSVCRT__)