From 2e24003aba101eaf07c44f8efa08faa337d020c7 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 21 May 2020 21:33:48 +0200 Subject: context: Ensure constructor runs after talloc constructor Change-Id: Ia41838d4b997b7bed9f5daf8db3c0f67ba6cd744 Closes: OS#4456 --- src/context.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/context.c b/src/context.c index bad012bd..9792b88f 100644 --- a/src/context.c +++ b/src/context.c @@ -43,8 +43,11 @@ int osmo_ctx_init(const char *id) return 0; } -/* initialize osmo_ctx on main tread */ -static __attribute__((constructor)) void on_dso_load_ctx(void) +/* initialize osmo_ctx on main thread. Use a very large priority value + * for the constructor attribute in order to ensure this is called after the + * talloc-internal constructor, which is setting up the randomized magic value + * in talloc_lib_init(). */ +static __attribute__((constructor(65535))) void on_dso_load_ctx(void) { OSMO_ASSERT(osmo_ctx_init("main") == 0); } -- cgit v1.2.3