diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-10-09 16:02:55 +0200 |
---|---|---|
committer | Sven Eden <sven.eden@prydeworx.com> | 2018-10-29 10:18:31 +0100 |
commit | c38cb76e8aa42dcdbe5dacc0da55952a84afa7a6 (patch) | |
tree | 35bf6c86b53462c722e64104062ceec64eff3e73 | |
parent | f02a0332640a57eefab440123b57ab1b3c8cd0d6 (diff) |
mempool: only enable mempool use when linked to libsystemd-shared.so
Mempool use is enabled or disabled based on the mempool_use_allowed symbol that
is linked in.
Should fix assert crashes in external programs caused by #9792.
Replaces #10286.
v2:
- use two different source files instead of a gcc constructor
(cherry picked from commit a5d8835c78112206bbf0812dd4cb471f803bfe88)
-rw-r--r-- | meson.build | 3 | ||||
-rw-r--r-- | src/basic/mempool.c | 2 | ||||
-rw-r--r-- | src/basic/mempool.h | 3 | ||||
-rw-r--r-- | src/libelogind/disable-mempool.c | 5 | ||||
-rw-r--r-- | src/libelogind/meson.build | 30 | ||||
-rw-r--r-- | src/shared/enable-mempool.c | 5 | ||||
-rw-r--r-- | src/shared/meson.build | 1 |
7 files changed, 34 insertions, 15 deletions
diff --git a/meson.build b/meson.build index 36163550b..0351ad820 100644 --- a/meson.build +++ b/meson.build @@ -1567,6 +1567,7 @@ libelogind_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libelogind_sy libelogind = shared_library( 'elogind', version : libelogind_version, + disable_mempool_c, include_directories : includes, link_args : ['-shared', '-Wl,--version-script=' + libelogind_sym_path], @@ -1673,6 +1674,7 @@ subdir('src/test') test_dlopen = executable( 'test-dlopen', test_dlopen_c, + disable_mempool_c, include_directories : includes, link_with : [libbasic], dependencies : [libdl]) @@ -1693,6 +1695,7 @@ test_dlopen = executable( # nss = shared_library( # 'nss_' + module, # 'src/nss-@0@/nss-@0@.c'.format(module), +# disable_mempool_c, # version : '2', # include_directories : includes, # # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned diff --git a/src/basic/mempool.c b/src/basic/mempool.c index aaf46ceda..24a7d2b11 100644 --- a/src/basic/mempool.c +++ b/src/basic/mempool.c @@ -78,6 +78,8 @@ bool mempool_enabled(void) { if (!is_main_thread()) return false; + if (!mempool_use_allowed) + b = false; if (b < 0) b = getenv_bool("SYSTEMD_MEMPOOL") != 0; diff --git a/src/basic/mempool.h b/src/basic/mempool.h index e223fc16f..a9d6b4691 100644 --- a/src/basic/mempool.h +++ b/src/basic/mempool.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #pragma once - +//#include <stdbool.h> #include <stddef.h> struct pool; @@ -23,6 +23,7 @@ static struct mempool pool_name = { \ .at_least = alloc_at_least, \ } +extern const bool mempool_use_allowed; bool mempool_enabled(void); #if VALGRIND diff --git a/src/libelogind/disable-mempool.c b/src/libelogind/disable-mempool.c new file mode 100644 index 000000000..c86e55340 --- /dev/null +++ b/src/libelogind/disable-mempool.c @@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ + +//#include "mempool.h" + +const bool mempool_use_allowed = false; diff --git a/src/libelogind/meson.build b/src/libelogind/meson.build index dfecea3bc..2e5e8706a 100644 --- a/src/libelogind/meson.build +++ b/src/libelogind/meson.build @@ -80,6 +80,14 @@ sd_login_c = files('sd-login/sd-login.c') # sd-resolve/sd-resolve.c # sd-utf8/sd-utf8.c # '''.split()) + id128_sources + sd_daemon_c + sd_event_c + sd_login_c +# +# disable_mempool_c = files('disable-mempool.c') +# +# libsystemd_c_args = ['-fvisibility=default'] +# +# libsystemd_static = static_library( +# 'systemd_static', +# libsystemd_sources, #else libelogind_sources = files(''' sd-bus/bus-common-errors.c @@ -126,28 +134,22 @@ libelogind_sources = files(''' sd-id128/sd-id128.c '''.split()) + sd_login_c #endif // 0 - -libelogind_c_args = ['-fvisibility=default'] - -libelogind_static = static_library( - 'elogind_static', - libelogind_sources, install : false, include_directories : includes, link_with : libbasic, #if 0 /// elogind does not need librt # dependencies : [threads, # librt], +# c_args : libsystemd_c_args) +# +# libsystemd_sym = 'src/libsystemd/libsystemd.sym' +# +# libsystemd_pc = configure_file( +# input : 'libsystemd.pc.in', +# output : 'libsystemd.pc', +# install_data(libsystemd_pc, #else dependencies : [threads], #endif // 0 - c_args : libelogind_c_args) - -libelogind_sym = 'src/libelogind/libelogind.sym' - -libelogind_pc = configure_file( - input : 'libelogind.pc.in', - output : 'libelogind.pc', configuration : substs) -install_data(libelogind_pc, install_dir : pkgconfiglibdir) diff --git a/src/shared/enable-mempool.c b/src/shared/enable-mempool.c new file mode 100644 index 000000000..68d817f55 --- /dev/null +++ b/src/shared/enable-mempool.c @@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ + +//#include "mempool.h" + +const bool mempool_use_allowed = true; diff --git a/src/shared/meson.build b/src/shared/meson.build index e5cd4d60c..a48bee9c7 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -37,6 +37,7 @@ # dropin.h # efivars.c # efivars.h +# enable-mempool.c # fdset.c # fdset.h # firewall-util.h |