accellera-official / uvm-core

Apache License 2.0
56 stars 19 forks source link

Static races in `static const` declarations #6

Closed jrefice closed 6 months ago

jrefice commented 8 months ago

Copied from Mantis 8376:

Hi Everyone

Want to bring to a notice and we should fix following race condition.

Inside uvm_cmd_line_report.svh

there is a race between two declarations with init. there is a group of classes in the new uvm uvmcmdline* that all follow the same 'broken' pattern. there is a 'static const xx ' class member with initialisation. the idea is to make a local const BUT the assignment is not guaranteed to have executed before it is used. we tried a change from 'static const' to 'localparam'

35: //static const string prefix = "+UVM_VERBOSITY=";

Change : localparam string prefix = "+UVM_VERBOSITY=";

Thanks and Regards Shobhit Kapoor

Noting that this pattern repeats in a few places:

src/base/uvm_cmdline_report.svh:46:  static const string prefix = "+UVM_VERBOSITY=";
src/base/uvm_cmdline_report.svh:183:  static const string prefix = "+uvm_set_verbosity="; 
src/base/uvm_cmdline_report.svh:379:  static const string prefix="+uvm_set_action=";
src/base/uvm_cmdline_report.svh:509:  static const string prefix="+uvm_set_severity=";
src/base/uvm_spell_chkr.svh:42:  static const int unsigned max = '1;

src/base/uvm_report_catcher.svh:90:  const static int DO_NOT_CATCH      = 1; 
src/base/uvm_report_catcher.svh:91:  const static int DO_NOT_MODIFY     = 2; 
src/comps/uvm_random_stimulus.svh:59:  const static string type_name = "uvm_random_stimulus #(T)";
src/deprecated/macros/uvm_object_defines.svh:506://| const static string type_name = TNAME_STRING;
src/deprecated/macros/uvm_object_defines.svh:516:     const static string type_name = TNAME_STRING; \