LexActivator Leaking Memory C++ in latest version

I updated to the latest version. I’m about to make a release later this month. Valgrind found the following issue. Previous to this, I had activated a trial but was running the activated code offline. Valgrind log follows (XML format)

<?xml version="1.0"?>

4
memcheck

Memcheck, a memory error detector Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. Using Valgrind-3.16.0 and LibVEX; rerun with -h for copyright info Command: /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp --cfg /home/jgreninger/Projects/protocol++/tests/wifi.testpp --log /home/jgreninger/Projects/protocol++/jetbrains.log

27708
27215
memcheck

/usr/bin/valgrind --tool=memcheck --xml=yes --xml-file=/tmp/clion-valgrind845be2bd-4cac-4b66-bb47-8a4b0db1820c/valgrind_output_%p --gen-suppressions=all --leak-check=full --leak-resolution=med --track-origins=yes --vgdb=no /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp --cfg /home/jgreninger/Projects/protocol++/tests/wifi.testpp --log /home/jgreninger/Projects/protocol++/jetbrains.log RUNNING 00:00:00:00.567 0x0 1 UninitCondition Conditional jump or move depends on uninitialised value(s) 0x4C38338 /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so strlen /builddir/build/BUILD/valgrind-3.16.0/memcheck/../shared vg_replace_strmem.c 459 0x5B595E4 /usr/lib64/libstdc++.so.6.0.25 std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) 0xBB6602 /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp LexActivator::GetMacAddress(std::string&, std::string&, std::string&) 0xBB7B57 /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp LexActivator::LexGenLinuxFingerPrint(std::string&, std::string&, std::string&, std::string&, std::string&, std::string&, std::string&) 0xBC6687 /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp LexActivator::LexSystemInfo::GetFingerprint(LexActivator::LinuxFingerprint&) 0xBC6992 /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp LexActivator::LexSystemInfo::GetFingerprint() 0xBBFB3A /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp LexActivator::LexValidator::MatchFingerprint(std::string, std::string) 0xBC0617 /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp LexActivator::LexValidator::ValidateTrialActivation(std::string, std::string, std::string, LexActivator::TrialActivationPayload&, bool) 0xBAC69D /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp IsTrialGenuine 0xA8EF02 /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp chkLicense() /home/jgreninger/Projects/protocol++ jtestbench/src/jbuilder.cpp 568 0xA8F392 /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp main /home/jgreninger/Projects/protocol++ jtestbench/src/jbuilder.cpp 635 Uninitialised value was created by a stack allocation 0xBB6444 /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp LexActivator::GetMacAddress(std::string&, std::string&, std::string&) insert_a_suppression_name_here Memcheck:Cond strlen _ZNSsC1EPKcRKSaIcE _ZN12LexActivator13GetMacAddressERSsS0_S0_ _ZN12LexActivator22LexGenLinuxFingerPrintERSsS0_S0_S0_S0_S0_S0_ _ZN12LexActivator13LexSystemInfo14GetFingerprintERNS_16LinuxFingerprintE _ZN12LexActivator13LexSystemInfo14GetFingerprintEv _ZN12LexActivator12LexValidator16MatchFingerprintESsSs _ZN12LexActivator12LexValidator23ValidateTrialActivationESsSsSsRNS_22TrialActivationPayloadEb IsTrialGenuine _Z10chkLicensev main <![CDATA[ { Memcheck:Cond fun:strlen fun:_ZNSsC1EPKcRKSaIcE fun:_ZN12LexActivator13GetMacAddressERSsS0_S0_ fun:_ZN12LexActivator22LexGenLinuxFingerPrintERSsS0_S0_S0_S0_S0_S0_ fun:_ZN12LexActivator13LexSystemInfo14GetFingerprintERNS_16LinuxFingerprintE fun:_ZN12LexActivator13LexSystemInfo14GetFingerprintEv fun:_ZN12LexActivator12LexValidator16MatchFingerprintESsSs fun:_ZN12LexActivator12LexValidator23ValidateTrialActivationESsSsSsRNS_22TrialActivationPayloadEb fun:IsTrialGenuine fun:_Z10chkLicensev fun:main } ]]> insert_a_suppression_name_here Memcheck:Cond strlen _ZNSsC1EPKcRKSaIcE _ZN12LexActivator13GetMacAddressERSsS0_S0_ _ZN12LexActivator22LexGenLinuxFingerPrintERSsS0_S0_S0_S0_S0_S0_ _ZN12LexActivator13LexSystemInfo14GetFingerprintERNS_16LinuxFingerprintE _ZN12LexActivator13LexSystemInfo14GetFingerprintEv _ZN12LexActivator12LexValidator16MatchFingerprintESsSs _ZN12LexActivator12LexValidator23ValidateTrialActivationESsSsSsRNS_22TrialActivationPayloadEb IsTrialGenuine _Z10chkLicensev main <![CDATA[ { Memcheck:Cond fun:strlen fun:_ZNSsC1EPKcRKSaIcE fun:_ZN12LexActivator13GetMacAddressERSsS0_S0_ fun:_ZN12LexActivator22LexGenLinuxFingerPrintERSsS0_S0_S0_S0_S0_S0_ fun:_ZN12LexActivator13LexSystemInfo14GetFingerprintERNS_16LinuxFingerprintE fun:_ZN12LexActivator13LexSystemInfo14GetFingerprintEv fun:_ZN12LexActivator12LexValidator16MatchFingerprintESsSs fun:_ZN12LexActivator12LexValidator23ValidateTrialActivationESsSsSsRNS_22TrialActivationPayloadEb fun:IsTrialGenuine fun:_Z10chkLicensev fun:main } ]]> FINISHED 00:00:06:39.219 4 0x0 <?xml version="1.0"?>

4
memcheck

Memcheck, a memory error detector Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. Using Valgrind-3.16.0 and LibVEX; rerun with -h for copyright info Command: /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp --cfg /home/jgreninger/Projects/protocol++/tests/wifi.testpp --log /home/jgreninger/Projects/protocol++/jetbrains.log

27734
27708
memcheck

/usr/bin/valgrind --tool=memcheck --xml=yes --xml-file=/tmp/clion-valgrind845be2bd-4cac-4b66-bb47-8a4b0db1820c/valgrind_output_%p --gen-suppressions=all --leak-check=full --leak-resolution=med --track-origins=yes --vgdb=no /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp --cfg /home/jgreninger/Projects/protocol++/tests/wifi.testpp --log /home/jgreninger/Projects/protocol++/jetbrains.log <?xml version="1.0"?>

4
memcheck

Memcheck, a memory error detector Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. Using Valgrind-3.16.0 and LibVEX; rerun with -h for copyright info Command: /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp --cfg /home/jgreninger/Projects/protocol++/tests/wifi.testpp --log /home/jgreninger/Projects/protocol++/jetbrains.log

27737
27708
memcheck

/usr/bin/valgrind --tool=memcheck --xml=yes --xml-file=/tmp/clion-valgrind845be2bd-4cac-4b66-bb47-8a4b0db1820c/valgrind_output_%p --gen-suppressions=all --leak-check=full --leak-resolution=med --track-origins=yes --vgdb=no /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp --cfg /home/jgreninger/Projects/protocol++/tests/wifi.testpp --log /home/jgreninger/Projects/protocol++/jetbrains.log <?xml version="1.0"?>

4
memcheck

Memcheck, a memory error detector Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. Using Valgrind-3.16.0 and LibVEX; rerun with -h for copyright info Command: /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp --cfg /home/jgreninger/Projects/protocol++/tests/wifi.testpp --log /home/jgreninger/Projects/protocol++/jetbrains.log

27739
27708
memcheck

/usr/bin/valgrind --tool=memcheck --xml=yes --xml-file=/tmp/clion-valgrind845be2bd-4cac-4b66-bb47-8a4b0db1820c/valgrind_output_%p --gen-suppressions=all --leak-check=full --leak-resolution=med --track-origins=yes --vgdb=no /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp --cfg /home/jgreninger/Projects/protocol++/tests/wifi.testpp --log /home/jgreninger/Projects/protocol++/jetbrains.log <?xml version="1.0"?>

4
memcheck

Memcheck, a memory error detector Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. Using Valgrind-3.16.0 and LibVEX; rerun with -h for copyright info Command: /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp --cfg /home/jgreninger/Projects/protocol++/tests/wifi.testpp --log /home/jgreninger/Projects/protocol++/jetbrains.log

27741
27708
memcheck

/usr/bin/valgrind --tool=memcheck --xml=yes --xml-file=/tmp/clion-valgrind845be2bd-4cac-4b66-bb47-8a4b0db1820c/valgrind_output_%p --gen-suppressions=all --leak-check=full --leak-resolution=med --track-origins=yes --vgdb=no /home/jgreninger/Projects/protocol++/cmake-build-debug/protocolpp --cfg /home/jgreninger/Projects/protocol++/tests/wifi.testpp --log /home/jgreninger/Projects/protocol++/jetbrains.log

Hi,

The valgrind output you have shared doesn’t point to any memory leak, it just points to an error:

Conditional jump or move depends on uninitialised value

Which in this particular case is expected due to the logic of the function.

Ok…so you’re not going to initialize a variable you make decision with or check for a nullptr?

In C++ a variable of type string is auto-initialized to an empty string and in this particular case empty string is also a valid return value for the variable.

I have dozens of std::string that are initialized like this

std::string mystring;

and valgrind hasn’t flagged a single one. If I remove the licensing code, my code runs leak valgrind free

9bb785_c3879887468a4add9d2191c98d4d4908.pdf (filesusr.com)

I insist again that it is not a leak, the variable is created on the stack. And we will initialize it in the next version when it will be scheduled so that you don’t get any warnings.