diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2023-06-13 20:40:53 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2023-06-14 07:24:36 +0200 |
commit | 0408e5344b5c43bc3384c264588e1d49770fd2dc (patch) | |
tree | 4533fc50ec7d2aa5207b89e288e089ea2d782f99 /external/coinmp | |
parent | ec60d354359067f8c5c686ef2239ee705916de43 (diff) |
external/coinmap: Address ODR violations
...since 2193650b3373ee1889961cfb72d1fe97f73e2c23 "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 2193650b3373ee1889961cfb72d1fe97f73e2c23
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>
Diffstat (limited to 'external/coinmp')
-rw-r--r-- | external/coinmp/UnpackedTarball_coinmp.mk | 1 | ||||
-rw-r--r-- | external/coinmp/odr.patch | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/external/coinmp/UnpackedTarball_coinmp.mk b/external/coinmp/UnpackedTarball_coinmp.mk index 75fa5aaf653a..83ebfca80193 100644 --- a/external/coinmp/UnpackedTarball_coinmp.mk +++ b/external/coinmp/UnpackedTarball_coinmp.mk @@ -46,6 +46,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,coinmp,\ external/coinmp/pedantic-errors.patch \ external/coinmp/bind2nd.patch.1 \ external/coinmp/clang-with-path.patch \ + external/coinmp/odr.patch \ )) # vim: set noet sw=4 ts=4: diff --git a/external/coinmp/odr.patch b/external/coinmp/odr.patch new file mode 100644 index 000000000000..6e91c86415d2 --- /dev/null +++ b/external/coinmp/odr.patch @@ -0,0 +1,30 @@ +--- 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__) |