Domino Valdano created MADLIB-1355:
--------------------------------------
Summary: Hide all global symbols in libmadlib.so by default
Key: MADLIB-1355
URL: https://issues.apache.org/jira/browse/MADLIB-1355
Project: Apache MADlib
Issue Type: Task
Components: All Modules
Reporter: Domino Valdano
Fix For: v1.16
There was an intermittent crash in the deep_learning module due to both
_tensorflow_ and _madlib_ using the same STL class (_std::set<string>_), and
the functions in this class being publicly exported from _libmadlib.so_
We fixed the crash by adding the symbols for the _std::set<string>_ functions
to the list of symbols the linker should hide during the build process. But we
left a lot of other visible global symbols exported that shouldn't be
exported... in order to be avoid extensive testing to make sure it doesn't
break anything on an obscure platform or for some configurations.
Without doing this, we will always run the risk that there is another library
we are using (could be very indirect, such as with this case where python
imports a module which then calls a C library) that conflicts with the version
of STL or Boost that _madlib_ is using. If that happens, we could easily have
another unexplained crash and it would be very difficult again to track down.
The recommended best practice for exporting symbols from a shared object file
is that we should hide everything by default, and only expose those functions
which are officially a part of our API.
We can hide everything by default by adding _-fvisibility=hidden_ to the list
of default params to pass to the compiler in the master _CMakeLists.txt_. This
will cause gcc to hide all symbols from external libraries by default. In
addition, we should use either a #pragma or by adding a macro to prefix
function definitions with that sets the visibility on specific functions we
want to expose to default (visible). We can remove the
_-unexported_symbols_list_ property from OSX and _--version-script_ property
from other platforms, as these will no longer be needed. We should also delete
the files they reference, _library.ver_ and _unexported_symbols_list.txt_
Two good references on how to control visibility of symbols:
[https://developer.apple.com/library/archive/technotes/tn2185/_index.html]
[https://gcc.gnu.org/wiki/Visibility]
Hopefully the list of symbols we need to expose is just the list of sql
functions implemented in C, but there may be a few others that also need to be
exposed.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)