Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: With multi routing managers, using 2 different "diagnosis" fail giving the expected result #845

Open
angroyer opened this issue Feb 7, 2025 · 2 comments
Labels

Comments

@angroyer
Copy link

angroyer commented Feb 7, 2025

vSomeip Version

v3.4.9

Boost Version

1.76.0

Environment

Embedded Linux

Describe the bug

In a multi routing manager scenario, I define a different "diagnosis" field in each .json file.

When running, the same "diagnosis" value is used for both routing managers: it is the value used by the routing manager that receives the first client connection. The issue is in function "utility::request_client_id(...)".

Here is the fix: remove the usage of static that act as global variables.

diff --git a/implementation/utility/src/utility.cpp b/implementation/utility/src/utility.cpp
index e7065f0c..800b40bf 100644
--- a/implementation/utility/src/utility.cpp
+++ b/implementation/utility/src/utility.cpp
@@ -187,14 +187,14 @@ utility::request_client_id(
         const std::shared_ptr<configuration> &_config,
         const std::string &_name, client_t _client) {
     std::lock_guard<std::mutex> its_lock(mutex__);
-    static const std::uint16_t its_max_num_clients = get_max_client_number(_config);
+    const std::uint16_t its_max_num_clients = get_max_client_number(_config);

-    static const std::uint16_t its_diagnosis_mask = _config->get_diagnosis_mask();
-    static const std::uint16_t its_client_mask = static_cast<std::uint16_t>(~its_diagnosis_mask);
-    static const client_t its_masked_diagnosis_address = static_cast<client_t>(
+    const std::uint16_t its_diagnosis_mask = _config->get_diagnosis_mask();
+    const std::uint16_t its_client_mask = static_cast<std::uint16_t>(~its_diagnosis_mask);
+    const client_t its_masked_diagnosis_address = static_cast<client_t>(
             (_config->get_diagnosis_address() << 8) & its_diagnosis_mask);
-    static const client_t its_biggest_client = its_masked_diagnosis_address | its_client_mask;
-    static const client_t its_smallest_client = its_masked_diagnosis_address;
+    const client_t its_biggest_client = its_masked_diagnosis_address | its_client_mask;
+    const client_t its_smallest_client = its_masked_diagnosis_address;

     auto r = data__.find(_config->get_network());
     if (r == data__.end())

Reproduction Steps

No response

Expected behaviour

Apply the "diagnosis" value of each routing manager.

Logs and Screenshots

No response

@angroyer angroyer added the bug label Feb 7, 2025
@Pascal-Fremaux
Copy link

@Pascal-Fremaux
Copy link

The real issue is not that they are global, but that in C++ a static variable instruction (in a function) is executed only the very first time. The fact that they are also const reenforced the problem, forcing the first instance to define its prefix and mask for the whole ECU.
As reminder, the function utility::request_client_id() is reused by several application_impl and several routing managers. Each has its own diagnoses, max number of clients, etc.

But to make the ClientIds unique overall, as requested by the reqs, the "map" used to store the defined ClientId must be unique (on ECU).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants