Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH 1/1] test: stop linking msgpuck lib with test modules
@ 2020-05-27 22:17 Vladislav Shpilevoy
  2020-05-28 20:01 ` Timur Safin
  2020-05-28 22:15 ` Vladislav Shpilevoy
  0 siblings, 2 replies; 3+ messages in thread
From: Vladislav Shpilevoy @ 2020-05-27 22:17 UTC (permalink / raw)
  To: tarantool-patches, avtikhon, tsafin

Test modules are shared libraries. They link with Tarantool at
runtime and resolve missing symbols then. However in case they
already contain some of the same symbols used by tarantool, that
leads to a conflict in ASAN build. Nothing serious, there are
strict rules how a linker should behave in this case, but there
is still a warning. This is how it looked (the text is shortened):

    ==25624==ERROR: AddressSanitizer: odr-violation (0x000001123b60):
      [1] size=1024 'mp_type_hint' /builds/nZUxDh2c/0/tarantool/tarantool/src/lib/msgpuck/hints.c:39:20
      [2] size=1024 'mp_type_hint' /builds/nZUxDh2c/0/tarantool/tarantool/src/lib/msgpuck/hints.c:39:20
    These globals were registered at these points:
      [1]:
        #0 0x478b8e in __asan_register_globals (/builds/nZUxDh2c/0/tarantool/tarantool/src/tarantool+0x478b8e)
        #1 0x7ff7a9bc9d0b in asan.module_ctor (/tmp/tntz2FLhA/function1.so+0x6d0b)

      [2]:
        #0 0x478b8e in __asan_register_globals (/builds/nZUxDh2c/0/tarantool/tarantool/src/tarantool+0x478b8e)
        #1 0xab990b in asan.module_ctor (/builds/nZUxDh2c/0/tarantool/tarantool/src/tarantool+0xab990b)

The symbol mp_type_hint is defined both in tarantool executable,
and in function1.so dynamic library. This is because both build
with msgpuck static library.

However the modules don't need to be built with msgpuck. They can
link with it at runtime from tarantool executable.

This patch removes msgpuck from test dynamic modules, and exports
all msgpuck non-inlined symbols explicitly, so they couldn't be
removed by the linker in future.

Follow-up #2971
Follow-up #5001
Closes #5023
---
Branch: http://github.com/tarantool/tarantool/tree/gerold103/gh-5023-msgpuck-conflict-full-ci
Issue: https://github.com/tarantool/tarantool/issues/5023

 src/exports.h       | 14 ++++++++++++++
 test/CMakeLists.txt |  1 -
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/exports.h b/src/exports.h
index bffb1636b..29797ae5a 100644
--- a/src/exports.h
+++ b/src/exports.h
@@ -319,6 +319,7 @@ EXPORT(luaT_istuple)
 EXPORT(luaT_pushtuple)
 EXPORT(luaT_state)
 EXPORT(luaT_tolstring)
+EXPORT(mp_char2escape)
 EXPORT(mp_decode_double)
 EXPORT(mp_decode_extl)
 EXPORT(mp_decode_float)
@@ -326,8 +327,21 @@ EXPORT(mp_encode_decimal)
 EXPORT(mp_encode_double)
 EXPORT(mp_encode_float)
 EXPORT(mp_encode_uuid)
+EXPORT(mp_ext_hint)
+EXPORT(mp_format)
+EXPORT(mp_fprint)
+EXPORT(mp_fprint_ext)
+EXPORT(mp_fprint_ext_default)
+EXPORT(mp_fprint_recursion)
+EXPORT(mp_parser_hint)
 EXPORT(mp_sizeof_decimal)
 EXPORT(mp_sizeof_uuid)
+EXPORT(mp_snprint)
+EXPORT(mp_snprint_ext)
+EXPORT(mp_snprint_ext_default)
+EXPORT(mp_snprint_recursion)
+EXPORT(mp_type_hint)
+EXPORT(mp_vformat)
 EXPORT(password_prepare)
 EXPORT(PMurHash32)
 EXPORT(PMurHash32_Process)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 37cc099b7..8d9d0462a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -5,7 +5,6 @@ include_directories(${MSGPUCK_INCLUDE_DIRS})
 
 function(build_module module files)
     add_library(${module} SHARED ${files})
-    target_link_libraries(${module} ${MSGPUCK_LIBRARIES})
     set_target_properties(${module} PROPERTIES PREFIX "")
     add_dependencies(${module} api)
     if(TARGET_OS_DARWIN)
-- 
2.21.1 (Apple Git-122.3)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/1] test: stop linking msgpuck lib with test modules
  2020-05-27 22:17 [Tarantool-patches] [PATCH 1/1] test: stop linking msgpuck lib with test modules Vladislav Shpilevoy
@ 2020-05-28 20:01 ` Timur Safin
  2020-05-28 22:15 ` Vladislav Shpilevoy
  1 sibling, 0 replies; 3+ messages in thread
From: Timur Safin @ 2020-05-28 20:01 UTC (permalink / raw)
  To: 'Vladislav Shpilevoy', tarantool-patches, avtikhon

Huh, indeed, very correct idea to link testing executable 
with msgpuck from Tarantool executable! 

LGTM!

Timur

: -----Original Message-----
: From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
: Sent: Thursday, May 28, 2020 1:18 AM
: To: tarantool-patches@dev.tarantool.org; avtikhon@tarantool.org;
: tsafin@tarantool.org
: Subject: [PATCH 1/1] test: stop linking msgpuck lib with test modules
: 
: Test modules are shared libraries. They link with Tarantool at
: runtime and resolve missing symbols then. However in case they
: already contain some of the same symbols used by tarantool, that
: leads to a conflict in ASAN build. Nothing serious, there are
: strict rules how a linker should behave in this case, but there
: is still a warning. This is how it looked (the text is shortened):
: 
:     ==25624==ERROR: AddressSanitizer: odr-violation (0x000001123b60):
:       [1] size=1024 'mp_type_hint'
: /builds/nZUxDh2c/0/tarantool/tarantool/src/lib/msgpuck/hints.c:39:20
:       [2] size=1024 'mp_type_hint'
: /builds/nZUxDh2c/0/tarantool/tarantool/src/lib/msgpuck/hints.c:39:20
:     These globals were registered at these points:
:       [1]:
:         #0 0x478b8e in __asan_register_globals
: (/builds/nZUxDh2c/0/tarantool/tarantool/src/tarantool+0x478b8e)
:         #1 0x7ff7a9bc9d0b in asan.module_ctor
: (/tmp/tntz2FLhA/function1.so+0x6d0b)
: 
:       [2]:
:         #0 0x478b8e in __asan_register_globals
: (/builds/nZUxDh2c/0/tarantool/tarantool/src/tarantool+0x478b8e)
:         #1 0xab990b in asan.module_ctor
: (/builds/nZUxDh2c/0/tarantool/tarantool/src/tarantool+0xab990b)
: 
: The symbol mp_type_hint is defined both in tarantool executable,
: and in function1.so dynamic library. This is because both build
: with msgpuck static library.
: 
: However the modules don't need to be built with msgpuck. They can
: link with it at runtime from tarantool executable.
: 
: This patch removes msgpuck from test dynamic modules, and exports
: all msgpuck non-inlined symbols explicitly, so they couldn't be
: removed by the linker in future.
: 
: Follow-up #2971
: Follow-up #5001
: Closes #5023
: ---
: Branch: http://github.com/tarantool/tarantool/tree/gerold103/gh-5023-
: msgpuck-conflict-full-ci
: Issue: https://github.com/tarantool/tarantool/issues/5023
: 
:  src/exports.h       | 14 ++++++++++++++
:  test/CMakeLists.txt |  1 -
:  2 files changed, 14 insertions(+), 1 deletion(-)
: 
: diff --git a/src/exports.h b/src/exports.h
: index bffb1636b..29797ae5a 100644
: --- a/src/exports.h
: +++ b/src/exports.h
: @@ -319,6 +319,7 @@ EXPORT(luaT_istuple)
:  EXPORT(luaT_pushtuple)
:  EXPORT(luaT_state)
:  EXPORT(luaT_tolstring)
: +EXPORT(mp_char2escape)
:  EXPORT(mp_decode_double)
:  EXPORT(mp_decode_extl)
:  EXPORT(mp_decode_float)
: @@ -326,8 +327,21 @@ EXPORT(mp_encode_decimal)
:  EXPORT(mp_encode_double)
:  EXPORT(mp_encode_float)
:  EXPORT(mp_encode_uuid)
: +EXPORT(mp_ext_hint)
: +EXPORT(mp_format)
: +EXPORT(mp_fprint)
: +EXPORT(mp_fprint_ext)
: +EXPORT(mp_fprint_ext_default)
: +EXPORT(mp_fprint_recursion)
: +EXPORT(mp_parser_hint)
:  EXPORT(mp_sizeof_decimal)
:  EXPORT(mp_sizeof_uuid)
: +EXPORT(mp_snprint)
: +EXPORT(mp_snprint_ext)
: +EXPORT(mp_snprint_ext_default)
: +EXPORT(mp_snprint_recursion)
: +EXPORT(mp_type_hint)
: +EXPORT(mp_vformat)
:  EXPORT(password_prepare)
:  EXPORT(PMurHash32)
:  EXPORT(PMurHash32_Process)
: diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
: index 37cc099b7..8d9d0462a 100644
: --- a/test/CMakeLists.txt
: +++ b/test/CMakeLists.txt
: @@ -5,7 +5,6 @@ include_directories(${MSGPUCK_INCLUDE_DIRS})
: 
:  function(build_module module files)
:      add_library(${module} SHARED ${files})
: -    target_link_libraries(${module} ${MSGPUCK_LIBRARIES})
:      set_target_properties(${module} PROPERTIES PREFIX "")
:      add_dependencies(${module} api)
:      if(TARGET_OS_DARWIN)
: --
: 2.21.1 (Apple Git-122.3)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/1] test: stop linking msgpuck lib with test modules
  2020-05-27 22:17 [Tarantool-patches] [PATCH 1/1] test: stop linking msgpuck lib with test modules Vladislav Shpilevoy
  2020-05-28 20:01 ` Timur Safin
@ 2020-05-28 22:15 ` Vladislav Shpilevoy
  1 sibling, 0 replies; 3+ messages in thread
From: Vladislav Shpilevoy @ 2020-05-28 22:15 UTC (permalink / raw)
  To: tarantool-patches, avtikhon, tsafin

Pushed to master.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-28 22:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 22:17 [Tarantool-patches] [PATCH 1/1] test: stop linking msgpuck lib with test modules Vladislav Shpilevoy
2020-05-28 20:01 ` Timur Safin
2020-05-28 22:15 ` Vladislav Shpilevoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox