-
Notifications
You must be signed in to change notification settings - Fork 568
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
odb: protecting dbModule::makeUniqueDbModule()::name_id_map with a lock #6245
base: master
Are you sure you want to change the base?
odb: protecting dbModule::makeUniqueDbModule()::name_id_map with a lock #6245
Conversation
Signed-off-by: Lucas Yuki Imamura <[email protected]>
clang-tidy review says "All clean, LGTM! 👍" |
src/odb/src/db/dbModule.cpp
Outdated
@@ -559,11 +560,15 @@ dbModule* dbModule::makeUniqueDbModule(const char* cell_name, | |||
std::string module_name = orig_cell_name + '_' + std::string(inst_name); | |||
do { | |||
std::string full_name = module_name; | |||
|
|||
name_id_map_mutex.lock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its better to use std::unique_lock than manual lock and unlock calls (eg exception safety).
Signed-off-by: Lucas Yuki Imamura <[email protected]>
clang-tidy review says "All clean, LGTM! 👍" |
This does not seem like an acceptable solution. If you have multiple odb's won't calls to makeUniqueDbModule interfere with each other? |
Interfere in the sense that the numbering will depend on the order of the calls. It won't be a thread safety issue but it could cause some non-determinism in the names. |
I think the easiest thing to do is move name_id_map to be a non-persistent member of dbBlock. No lock is then needed and the extra memory will disappear on close. |
Protects the static variable name_id_map from the dbModule::makeUniqueDbModule method with a lock (issue #5981)