From 7c8675c5ef59499a63cb11f542b6b1697803d8f8 Mon Sep 17 00:00:00 2001 From: Einwich Date: Wed, 11 May 2022 07:34:13 +0200 Subject: [PATCH] uninitialized access wartnings removed: ==33083==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x7f36df113d73 in sc_dt::vec_cmp(int, unsigned int const*, int, unsigned int const*) /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/datatypes/int/sc_nbutils.h:427:3 #1 0x7f36df113d73 in sc_dt::vec_skip_and_cmp(int, unsigned int const*, int, unsigned int const*) /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/datatypes/int/sc_nbutils.h:500:10 #2 0x7f36df113d73 in sc_dt::compare_unsigned(int, int, int, unsigned int const*, int, int, int, unsigned int const*, int, int) /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/datatypes/int/sc_unsigned.cpp:2090:21 #3 0x7f36df13e1ab in sc_dt::operator==(sc_dt::sc_unsigned const&, sc_dt::sc_unsigned const&) /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/datatypes/int/sc_unsigned.cpp:1722:7 #4 0x7f36df13e1ab in sc_dt::operator!=(sc_dt::sc_unsigned const&, sc_dt::sc_unsigned const&) /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/datatypes/int/sc_nbcommon.inc:1930:13 #5 0x4ab2d4 in sc_main /builds/coseda/systemc/systemc-regressions/scripts/systemc/datatypes/misc/concat/test07/./test07/test07.cpp:119:5 #6 0x7f36dec273e5 in sc_elab_and_sim /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/kernel/sc_main_main.cpp:89:18 #7 0x7f36dec26f38 in main /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/kernel/sc_main.cpp:36:9 #8 0x7f36dd41a492 in __libc_start_main (/lib64/libc.so.6+0x23492) #9 0x42387d in _start (/builds/coseda/systemc/systemc-regressions/scripts/systemc/datatypes/misc/concat/test07/systemc.exe+0x42387d) Uninitialized value was stored to memory at #0 0x7f36def86e38 in sc_dt::sc_signed::concat_get_data(unsigned int*, int) const /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/datatypes/int/sc_signed.cpp:337:26 #1 0x4b9fae in sc_dt::sc_concatref::value() const /opt/systemc-latest/include/sysc/datatypes/misc/sc_concatref.h:265:41 #2 0x4ab087 in sc_main /builds/coseda/systemc/systemc-regressions/scripts/systemc/datatypes/misc/concat/test07/./test07/test07.cpp:119:5 #3 0x7f36dec273e5 in sc_elab_and_sim /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/kernel/sc_main_main.cpp:89:18 #4 0x7f36dec26f38 in main /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/kernel/sc_main.cpp:36:9 #5 0x7f36dd41a492 in __libc_start_main (/lib64/libc.so.6+0x23492) Uninitialized value was created by a heap allocation #0 0x4a8abb in operator new(unsigned long) (/builds/coseda/systemc/systemc-regressions/scripts/systemc/datatypes/misc/concat/test07/systemc.exe+0x4a8abb) #1 0x7f36debf6f3b in sc_core::sc_byte_heap::initialize(unsigned long) /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/utils/sc_temporary.h:96:19 #2 0x7f36debf6f3b in sc_core::sc_byte_heap::sc_byte_heap(unsigned long) /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/utils/sc_temporary.h:114:3 #3 0x7f36debf6f3b in __cxx_global_var_init /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/datatypes/misc/sc_concatref.cpp:55:30 #4 0x7f36debf6f3b in _GLOBAL__sub_I_sc_concatref.cpp /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/datatypes/misc/sc_concatref.cpp #5 0x7f36df4ae8b9 in call_init.part.0 (/lib64/ld-linux-x86-64.so.2+0xf8b9) SUMMARY: MemorySanitizer: use-of-uninitialized-value /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/datatypes/int/sc_nbutils.h:427:3 in sc_dt::vec_cmp(int, unsigned int const*, int, unsigned int const*) Exiting ==39132==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x6ba6ac in tlm_utils::simple_target_socket_b::bw_process::nb_transport_bw(tlm::tlm_generic_payload&, tlm::tlm_phase&, sc_core::sc_time&) /opt/systemc-latest/include/tlm_utils/simple_target_socket.h:157:13 #1 0x69bf2b in ExplicitATTarget::beginResponse() /builds/coseda/systemc/systemc-regressions/include/tlm/ExplicitATTarget.h:133:19 #2 0x7ff92cf43a94 in sc_core::sc_process_b::semantics() /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/kernel/sc_process.h:685:9 #3 0x7ff92cf43a94 in sc_core::sc_thread_cor_fn(void*) /builds/coseda/systemc/systemc-latest/objdir/src/sysc/../../../src/sysc/kernel/sc_thread_process.cpp:117:23 #4 0x7ff92d4be4bc (/opt/systemc-latest/lib-linux64/libsystemc-2.3.4.so+0x6b74bc) Uninitialized value was created by an allocation of 'target7' in the stack frame of function 'sc_main' #0 0x4f7fe0 in sc_main /builds/coseda/systemc/systemc-regressions/scripts/tlm/bus_dmi/./bus_dmi/bus_dmi.cpp:37 SUMMARY: MemorySanitizer: use-of-uninitialized-value /opt/systemc-latest/include/tlm_utils/simple_target_socket.h:157:13 in tlm_utils::simple_target_socket_b::bw_process::nb_transport_bw(tlm::tlm_generic_payload&, tlm::tlm_phase&, sc_core::sc_time&) Exiting --- src/sysc/utils/sc_temporary.h | 1 + src/tlm_utils/simple_target_socket.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sysc/utils/sc_temporary.h b/src/sysc/utils/sc_temporary.h index 152b0f913..86cf9e048 100644 --- a/src/sysc/utils/sc_temporary.h +++ b/src/sysc/utils/sc_temporary.h @@ -94,6 +94,7 @@ class SC_API sc_byte_heap { { delete [] m_bgn_p; m_bgn_p = new char[heap_size]; + std::memset(m_bgn_p, 0, heap_size); m_end_p = &m_bgn_p[heap_size]; m_next_p = m_bgn_p; } diff --git a/src/tlm_utils/simple_target_socket.h b/src/tlm_utils/simple_target_socket.h index 7e4c3a197..d39dcee65 100644 --- a/src/tlm_utils/simple_target_socket.h +++ b/src/tlm_utils/simple_target_socket.h @@ -548,7 +548,7 @@ class simple_target_socket_b bw_process m_bw_process; std::map m_pending_trans; sc_core::sc_event m_end_request; - transaction_type* m_current_transaction; + transaction_type* m_current_transaction = NULL; }; template< typename MODULE, unsigned int BUSWIDTH = 32