From ee6d38a770943b01d650c0e0ef06226d9e810315 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 13 Mar 2020 21:06:39 +0100 Subject: [PATCH] libc: prune session labels of forked processes This patch reduces the size of session labels for all services other than LOG, keeping only the last element. This avoids exceeding the maximum label length in the presence of deep fork hierarchies, e.g., for running the tool chain. Fixes #3700 --- repos/libports/src/lib/libc/fork.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/repos/libports/src/lib/libc/fork.cc b/repos/libports/src/lib/libc/fork.cc index 2bb030602..c0c5b3336 100644 --- a/repos/libports/src/lib/libc/fork.cc +++ b/repos/libports/src/lib/libc/fork.cc @@ -496,15 +496,19 @@ struct Libc::Forked_child : Child_policy, Child_ready if (_state == State::STARTING_UP && name == Clone_session::service_name()) service_ptr = &_local_clone_service.service; - if (name == Rom_session::service_name()) { - - /* - * Strip off the originating child name to allow the application of - * routing rules based on the leading path elements, regardless - * of which child in the process hierarchy requests a ROM. - */ + /* + * Strip off the originating child name regardless of which child in + * the process hierarchy requests the session. This way, we avoid + * overly long labels in the presence of deep fork nesting levels. + * + * We keep the label intact only for the LOG sessions to retain + * unambiguous debug messages. + */ + if (name != "LOG") rewritten_label = label.last_element(); + if (name == Rom_session::service_name()) { + try { service_ptr = &_local_rom_services.matching_service(name, label); } catch (...) { }