I run sudo valgrind --leak-check=full -v --track-origins=yes ./myprogram
The result is:
==31734== 1 errors in context 7 of 7:
==31734== Conditional jump or move depends on uninitialised value(s)
==31734== at 0x61CCCC: TlsProtocol::sendRecord(unsigned char const*, unsigned int, int, int, int, TlsEndpoint&, unsigned int, SocketParams&, LogBase&) (in /home/me/src/myprogram)
==31734== by 0x61D32E: TlsProtocol::sendHandshakeMessages(DataBuffer&, int, int, TlsEndpoint&, unsigned int, SocketParams&, LogBase&) (in /home/me/src/myprogram)
==31734== by 0x620B1C: TlsProtocol::sendClientHello(TlsEndpoint&, unsigned int, SocketParams&, LogBase&) (in /home/me/src/myprogram)
==31734== by 0x6265E7: TlsProtocol::clientHandshake2(TlsEndpoint&, unsigned int, SocketParams&, LogBase&) (in /home/me/src/myprogram)
==31734== by 0x627789: TlsProtocol::clientHandshake(char const*, int, TlsEndpoint&, unsigned int, SocketParams&, SharedCertChain*, LogBase&) (in /home/me/src/myprogram)
==31734== by 0x616855: SChannelChilkat::connectImplicitSsl(char const*, int, bool, int, unsigned int, unsigned int, SystemCerts&, SocketParams&, LogBase&, bool&, SharedCertChain*) (in /home/me/src/myprogram)
==31734== by 0x56DDEB: Socket2::connect2(char const*, int, bool, bool, int, SystemCerts&, unsigned int, unsigned int, SocketParams&, LogBase&, bool&, int&, SharedCertChain*) (in /home/me/src/myprogram)
==31734== by 0x56E24F: Socket2::socket2Connect(char const*, int, bool, bool, int, SystemCerts&, unsigned int, unsigned int, SocketParams&, LogBase&, bool&, int&, SharedCertChain*, ClsSocksClient&, ClsHttpProxyClient*) (in /home/me/src/myprogram)
==31734== by 0x514FD9: Imap::connectToImapServer(char const*, int, StringBuffer&, SharedCertChain*, SystemCerts&, ClsSocksClient&, ClsHttpProxyClient*, LogBase&, ProgressMonitor*) (in /home/me/src/myprogram)
==31734== by 0x48BB69: ClsImap::Connect(XString&, ProgressEvent*) (in /home/me/src/myprogram)
==31734== by 0x454A5D: CkImap::Connect(char const*) (in /home/me/src/myprogram)
==31734== by 0x422C2E: EmailSensorAlertConnection::Connect(char const*, int, bool, char const*, char const*) (emailconnection.cpp:150)
==31734== Uninitialised value was created by a heap allocation
==31734== at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31734== by 0x47F219: ClsImap::createNewCls() (in /home/me/src/myprogram)
==31734== by 0x4567EA: CkImap::CkImap() (in /home/me/src/myprogram)
==31734== by 0x422A13: EmailConnection::EmailConnection(std::string) (emailconnection.cpp:110)
==31734== by 0x41D364: IMAPConnectionFactory::getIMAPConnection() (imapconnectionfactory.cpp:46)
==31734== by 0x431362: main (myprogram.cpp:348)
==31734==
==31734== ERROR SUMMARY: 7 errors from 7 contexts (suppressed: 0 from 0)
Part of myprogram.cpp is:
bool connectRes = m_imap.Connect( server );//line 348
I try to find the uninitialized variable. It seems that it is in:ClsImap::createNewCls(). I used grep to search this function. This function is in libchilkat-e/lib/libchilkat-9.5.0.a. How to fix this problem? It seems that the problem is in the lib. So I can do nothing? Am I right?
Related
I have this very simple code snippet using opencv and LibTorch, which does not run for some reason.
#include <iostream>
#include <torch/script.h>
#include <opencv2/core/core.hpp>
int main() {
cv::Mat imgMat = cv::Mat::zeros(640, 640, CV_8UC3);
at::Tensor tensorImg = torch::from_blob(imgMat.data, {1, imgMat.rows, imgMat.cols, imgMat.channels()});
std::cout << tensorImg << "\n"; // problem here
return 0;
}
I have tried to compile it with clang and added undefined behaviour sanitizer, which gives the following errors:
UndefinedBehaviorSanitizer:DEADLYSIGNAL
==11549==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x7fffde2fa000 (pc 0x7fffe4039d08 bp 0x7fffdd7b4ed0 sp 0x7fffdd7b4e20 T11570)
==11549==The signal is caused by a READ memory access.
UndefinedBehaviorSanitizer:DEADLYSIGNAL
UndefinedBehaviorSanitizer:DEADLYSIGNAL
#0 0x7fffe4039d08 in void c10::function_ref<void (char**, long const*, long, long)>::callback_fn<auto at::TensorIteratorBase::loop_2d_from_1d<at::native::AVX2::copy_kernel(at::TensorIterator&, bool)::'lambda'()::operator()() const::'lambda10'()::operator()() const::'lambda'()::operator()() const::'lambda12'()::operator()() const::'lambda'(char**, long const*, long)>(at::native::AVX2::copy_kernel(at::TensorIterator&, bool)::'lambda'()::operator()() const::'lambda10'()::operator()() const::'lambda'()::operator()() const::'lambda12'()::operator()() const::'lambda'(char**, long const*, long) const&)::'lambda'(char**, long const*, long, long)>(long, char**, long const*, long, long) (/home/dani/Desktop/test/build/libtorch/lib/libtorch_cpu.so+0x54bed08) (BuildId: e03155c98263c3ef83236051d8610270872897af)
#1 0x7fffdfecf96f in at::TensorIteratorBase::serial_for_each(c10::function_ref<void (char**, long const*, long, long)>, at::Range) const (/home/dani/Desktop/test/build/libtorch/lib/libtorch_cpu.so+0x135496f) (BuildId: e03155c98263c3ef83236051d8610270872897af)
#2 0x7fffdfecfb2d in void at::internal::invoke_parallel<at::TensorIteratorBase::for_each(c10::function_ref<void (char**, long const*, long, long)>, long)::'lambda'(long, long)>(long, long, long, at::TensorIteratorBase::for_each(c10::function_ref<void (char**, long const*, long, long)>, long)::'lambda'(long, long) const&) (._omp_fn.0) (/home/dani/Desktop/test/build/libtorch/lib/libtorch_cpu.so+0x1354b2d) (BuildId: e03155c98263c3ef83236051d8610270872897af)
#3 0x7fffde41696d (/home/dani/Desktop/test/build/libtorch/lib/libgomp-52f2fd74.so.1+0x1696d) (BuildId: 9afb2d23e5127e68ba5ef6031eefc9d25b9b672b)
#4 0x7fffde79db42 in start_thread nptl/./nptl/pthread_create.c:442:8
#5 0x7fffde82f9ff misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
UndefinedBehaviorSanitizer can not provide additional info.
SUMMARY: UndefinedBehaviorSanitizer: SEGV (/home/dani/Desktop/test/build/libtorch/lib/libtorch_cpu.so+0x54bed08) (BuildId: e03155c98263c3ef83236051d8610270872897af) in void c10::function_ref<void (char**, long const*, long, long)>::callback_fn<auto at::TensorIteratorBase::loop_2d_from_1d<at::native::AVX2::copy_kernel(at::TensorIterator&, bool)::'lambda'()::operator()() const::'lambda10'()::operator()() const::'lambda'()::operator()() const::'lambda12'()::operator()() const::'lambda'(char**, long const*, long)>(at::native::AVX2::copy_kernel(at::TensorIterator&, bool)::'lambda'()::operator()() const::'lambda10'()::operator()() const::'lambda'()::operator()() const::'lambda12'()::operator()() const::'lambda'(char**, long const*, long) const&)::'lambda'(char**, long const*, long, long)>(long, char**, long const*, long, long)
==11549==ABORTING
Any idea what am I doing wrong?
As it turned out I was missing the option parameter at::kByte from the function torch::from_blob().
Edit:
Without this parameter LibTorch could not interpret the tensor, and gave a deadly signal. See the actual reason in #Dan Mašek's comment.
Based on the documentation
The TensorOptions specify additional configuration options for the
returned tensor, such as what type to interpret the data as.
The correct line is:
at::Tensor tensorImg = torch::from_blob(imgMat.data, {1, imgMat.rows, imgMat.cols, imgMat.channels()}, at::kByte);
When I try to compile Flutter in my environment(macOS、M1), I get the following error.
Can anyone tell me how to fix it?
~/development/engine/src# ninja -C out/host_debug_unopt
ninja: Entering directory `out/host_debug_unopt'
[4610/5246] ACTION //third_party/dart/runtime/bin:generate_snapshot_bin(//build/toolchain/mac:clang_arm64)
FAILED: clang_arm64/gen/third_party/dart/runtime/bin/vm_snapshot_data.bin clang_arm64/gen/third_party/dart/runtime/bin/vm_snapshot_instructions.bin clang_arm64/gen/third_party/dart/runtime/bin/isolate_snapshot_data.bin clang_arm64/gen/third_party/dart/runtime/bin/isolate_snapshot_instructions.bin
python3 ../../third_party/dart/build/gn_run_binary.py compiled_action clang_arm64/gen_snapshot --sound-null-safety --deterministic --snapshot_kind=core --vm_snapshot_data=clang_arm64/gen/third_party/dart/runtime/bin/vm_snapshot_data.bin --vm_snapshot_instructions=clang_arm64/gen/third_party/dart/runtime/bin/vm_snapshot_instructions.bin --isolate_snapshot_data=clang_arm64/gen/third_party/dart/runtime/bin/isolate_snapshot_data.bin --isolate_snapshot_instructions=clang_arm64/gen/third_party/dart/runtime/bin/isolate_snapshot_instructions.bin /Users/rentoezoe/development/engine/src/out/host_debug_unopt/clang_arm64/vm_platform_strong_stripped.dill
Command failed: ./clang_arm64/gen_snapshot --sound-null-safety --deterministic --snapshot_kind=core --vm_snapshot_data=clang_arm64/gen/third_party/dart/runtime/bin/vm_snapshot_data.bin --vm_snapshot_instructions=clang_arm64/gen/third_party/dart/runtime/bin/vm_snapshot_instructions.bin --isolate_snapshot_data=clang_arm64/gen/third_party/dart/runtime/bin/isolate_snapshot_data.bin --isolate_snapshot_instructions=clang_arm64/gen/third_party/dart/runtime/bin/isolate_snapshot_instructions.bin /Users/rentoezoe/development/engine/src/out/host_debug_unopt/clang_arm64/vm_platform_strong_stripped.dill
output: ../../third_party/dart/runtime/vm/cpuinfo_macos.cc: 42: error: unreachable code
version=2.15.0-110.0.dev (dev) (Wed Sep 15 09:12:52 2021 -0700) on "macos_x64"
pid=55356, thread=259, isolate_group=(nil)(0x0), isolate=(nil)(0x0)
isolate_instructions=0, vm_instructions=0
pc 0x000000010088fe00 fp 0x000000016f835de0 dart::Profiler::DumpStackTrace(void*)+0x90
pc 0x00000001005fa974 fp 0x000000016f835e00 dart::Assert::Fail(char const*, ...) const+0x28
pc 0x00000001007522d8 fp 0x000000016f836240 dart::CpuInfo::FieldContains(dart::CpuInfoIndices, char const*)+0xb0
pc 0x000000010075201c fp 0x000000016f836260 dart::HostCPUFeatures::Init()+0x64
pc 0x00000001007526f4 fp 0x000000016f836480 dart::Dart::DartInit(unsigned char const*, unsigned char const*, _Dart_Isolate* (*)(char const*, char const*, char const*, char const*, Dart_IsolateFlags*, void*, char**), bool (*)(void**, char**), void (*)(void*, void*), void (*)(void*, void*), void (*)(void*), void (*)(), void* (*)(char const*, bool), void (*)(unsigned char**, long*, void*), void (*)(void const*, long, void*), void (*)(void*), bool (*)(unsigned char*, long), _Dart_Handle* (*)(), bool, Dart_CodeObserver*)+0x2e0
pc 0x0000000100752c94 fp 0x000000016f836500 dart::Dart::Init(unsigned char const*, unsigned char const*, _Dart_Isolate* (*)(char const*, char const*, char const*, char const*, Dart_IsolateFlags*, void*, char**), bool (*)(void**, char**), void (*)(void*, void*), void (*)(void*, void*), void (*)(void*), void (*)(), void* (*)(char const*, bool), void (*)(unsigned char**, long*, void*), void (*)(void const*, long, void*), void (*)(void*), bool (*)(unsigned char*, long), _Dart_Handle* (*)(), bool, Dart_CodeObserver*)+0x74
pc 0x0000000100fbcf0c fp 0x000000016f836560 Dart_Initialize+0x68
pc 0x00000001005cd600 fp 0x000000016f836700 dart::bin::main(int, char**)+0x650
pc 0x00000001a0b21430 fp 0x000000016f836720 start+0x4
-- End of DumpStackTrace
[4611/5246] ACTION //flutter/lib/snapshot:generate_snapshot_bin(//build/toolchain/mac:clang_x64)
FAILED: gen/flutter/lib/snapshot/vm_isolate_snapshot.bin gen/flutter/lib/snapshot/vm_snapshot_instructions.bin gen/flutter/lib/snapshot/isolate_snapshot.bin gen/flutter/lib/snapshot/isolate_snapshot_instructions.bin
python3 ../../build/gn_run_binary.py clang_arm64/gen_snapshot --snapshot_kind=core --enable_mirrors=false --vm_snapshot_data=/Users/rentoezoe/development/engine/src/out/host_debug_unopt/gen/flutter/lib/snapshot/vm_isolate_snapshot.bin --vm_snapshot_instructions=/Users/rentoezoe/development/engine/src/out/host_debug_unopt/gen/flutter/lib/snapshot/vm_snapshot_instructions.bin --isolate_snapshot_data=/Users/rentoezoe/development/engine/src/out/host_debug_unopt/gen/flutter/lib/snapshot/isolate_snapshot.bin --isolate_snapshot_instructions=/Users/rentoezoe/development/engine/src/out/host_debug_unopt/gen/flutter/lib/snapshot/isolate_snapshot_instructions.bin --enable_asserts /Users/rentoezoe/development/engine/src/out/host_debug_unopt/flutter_patched_sdk/platform_strong.dill
../../third_party/dart/runtime/vm/cpuinfo_macos.cc: 42: error: unreachable code
version=2.15.0-110.0.dev (dev) (Wed Sep 15 09:12:52 2021 -0700) on "macos_x64"
pid=55354, thread=259, isolate_group=(nil)(0x0), isolate=(nil)(0x0)
isolate_instructions=0, vm_instructions=0
pc 0x000000010494be00 fp 0x000000016b779d40 dart::Profiler::DumpStackTrace(void*)+0x90
pc 0x00000001046b6974 fp 0x000000016b779d60 dart::Assert::Fail(char const*, ...) const+0x28
pc 0x000000010480e2d8 fp 0x000000016b77a1a0 dart::CpuInfo::FieldContains(dart::CpuInfoIndices, char const*)+0xb0
pc 0x000000010480e01c fp 0x000000016b77a1c0 dart::HostCPUFeatures::Init()+0x64
pc 0x000000010480e6f4 fp 0x000000016b77a3e0 dart::Dart::DartInit(unsigned char const*, unsigned char const*, _Dart_Isolate* (*)(char const*, char const*, char const*, char const*, Dart_IsolateFlags*, void*, char**), bool (*)(void**, char**), void (*)(void*, void*), void (*)(void*, void*), void (*)(void*), void (*)(), void* (*)(char const*, bool), void (*)(unsigned char**, long*, void*), void (*)(void const*, long, void*), void (*)(void*), bool (*)(unsigned char*, long), _Dart_Handle* (*)(), bool, Dart_CodeObserver*)+0x2e0
pc 0x000000010480ec94 fp 0x000000016b77a460 dart::Dart::Init(unsigned char const*, unsigned char const*, _Dart_Isolate* (*)(char const*, char const*, char const*, char const*, Dart_IsolateFlags*, void*, char**), bool (*)(void**, char**), void (*)(void*, void*), void (*)(void*, void*), void (*)(void*), void (*)(), void* (*)(char const*, bool), void (*)(unsigned char**, long*, void*), void (*)(void const*, long, void*), void (*)(void*), bool (*)(unsigned char*, long), _Dart_Handle* (*)(), bool, Dart_CodeObserver*)+0x74
pc 0x0000000105078f0c fp 0x000000016b77a4c0 Dart_Initialize+0x68
pc 0x0000000104689600 fp 0x000000016b77a660 dart::bin::main(int, char**)+0x650
pc 0x00000001a0b21430 fp 0x000000016b77a680 start+0x4
-- End of DumpStackTrace
[4619/5246] ACTION //third_party/dart/utils/kernel-service:kernel_service_dill(//build/toolchain/mac:clang_arm64)
ninja: build stopped: subcommand failed.
zsh: exit 1 ninja -C out/host_debug_unopt
Just before the above, I run the following.
(This is after preparing the engine in the environment at hand in the way described in this document.
https://github.com/flutter/flutter/wiki/Setting-up-the-Engine-development-environment)
~/development/engine/src# ./flutter/tools/gn --unoptimized
GOMA usage was specified but can't be found, falling back to local builds. Set the GOMA_DIR environment variable to fix GOMA.
Using prebuilt Dart SDK binary. If you are editing Dart sources and wish to compile the Dart SDK, set `--no-prebuilt-dart-sdk`.
Generating GN files in: out/host_debug_unopt
Generating Xcode projects took 113ms
Generating compile_commands took 26ms
Done. Made 585 targets from 221 files in 2943ms
I'm linking a library against opencv libraries. I noticed that when I run the unit test executable (using GTest) for that library, that valgrind reports a memory leak/conditional jump or move depends on uninitialised value, even when the test doesn't do anything at all (just empty test method).
I traced that issue back to a single line in my CMakeLists.txt - when I remove the linkage against opencv, the memory leak goes away. This is the releavant snippet:
find_package(OpenCV REQUIRED)
set(libImageSources src/SourceImageFile.cpp)
add_library(image SHARED ${libImageSources})
# removing this line fixes the leak:
target_link_libraries(image ${OpenCV_LIBS})
Otherwise when runnig an empty unit test, I get an error like this:
==18681== Memcheck, a memory error detector
==18681== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==18681== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==18681== Command: ./image_test /Users/max/Documents/playground/cpp/image-server/tests
==18681==
==18681== Conditional jump or move depends on uninitialised value(s)
==18681== at 0x7FFF5FC24A27: bcmp (in /usr/lib/dyld)
==18681== by 0x7FFF5FC11904: ImageLoaderMachO::validateFirstPages(linkedit_data_command const*, int, unsigned char const*, unsigned long, long long, ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC16B7A: ImageLoaderMachOCompressed::instantiateFromFile(char const*, int, unsigned char const*, unsigned long, unsigned long long, unsigned long long, stat const&, unsigned int, unsigned int, linkedit_data_command const*, encryption_info_command const*, ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC10A6E: ImageLoaderMachO::instantiateFromFile(char const*, int, unsigned char const*, unsigned long long, unsigned long long, stat const&, ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC038C2: dyld::loadPhase6(int, stat const&, char const*, dyld::LoadContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC08468: dyld::loadPhase5(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC08188: dyld::loadPhase4(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC07EED: dyld::loadPhase3(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC07642: dyld::loadPhase1(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC0347A: dyld::loadPhase0(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC0315E: dyld::load(char const*, dyld::LoadContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC08705: dyld::libraryLocator(char const*, bool, char const*, ImageLoader::RPathChain const*) (in /usr/lib/dyld)
==18681==
==18681== Use of uninitialised value of size 8
==18681== at 0x7FFF5FC24A3F: bcmp (in /usr/lib/dyld)
==18681== by 0x7FFF5FC11904: ImageLoaderMachO::validateFirstPages(linkedit_data_command const*, int, unsigned char const*, unsigned long, long long, ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC16B7A: ImageLoaderMachOCompressed::instantiateFromFile(char const*, int, unsigned char const*, unsigned long, unsigned long long, unsigned long long, stat const&, unsigned int, unsigned int, linkedit_data_command const*, encryption_info_command const*, ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC10A6E: ImageLoaderMachO::instantiateFromFile(char const*, int, unsigned char const*, unsigned long long, unsigned long long, stat const&, ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC038C2: dyld::loadPhase6(int, stat const&, char const*, dyld::LoadContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC08468: dyld::loadPhase5(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC08188: dyld::loadPhase4(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC07EED: dyld::loadPhase3(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC07642: dyld::loadPhase1(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC0347A: dyld::loadPhase0(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC0315E: dyld::load(char const*, dyld::LoadContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC08705: dyld::libraryLocator(char const*, bool, char const*, ImageLoader::RPathChain const*) (in /usr/lib/dyld)
==18681==
==18681== Use of uninitialised value of size 8
==18681== at 0x7FFF5FC24A44: bcmp (in /usr/lib/dyld)
==18681== by 0x7FFF5FC11904: ImageLoaderMachO::validateFirstPages(linkedit_data_command const*, int, unsigned char const*, unsigned long, long long, ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC16B7A: ImageLoaderMachOCompressed::instantiateFromFile(char const*, int, unsigned char const*, unsigned long, unsigned long long, unsigned long long, stat const&, unsigned int, unsigned int, linkedit_data_command const*, encryption_info_command const*, ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC10A6E: ImageLoaderMachO::instantiateFromFile(char const*, int, unsigned char const*, unsigned long long, unsigned long long, stat const&, ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC038C2: dyld::loadPhase6(int, stat const&, char const*, dyld::LoadContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC08468: dyld::loadPhase5(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC08188: dyld::loadPhase4(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC07EED: dyld::loadPhase3(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC07642: dyld::loadPhase1(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC0347A: dyld::loadPhase0(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC0315E: dyld::load(char const*, dyld::LoadContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC08705: dyld::libraryLocator(char const*, bool, char const*, ImageLoader::RPathChain const*) (in /usr/lib/dyld)
==18681==
==18681== Conditional jump or move depends on uninitialised value(s)
==18681== at 0x7FFF5FC11907: ImageLoaderMachO::validateFirstPages(linkedit_data_command const*, int, unsigned char const*, unsigned long, long long, ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC16B7A: ImageLoaderMachOCompressed::instantiateFromFile(char const*, int, unsigned char const*, unsigned long, unsigned long long, unsigned long long, stat const&, unsigned int, unsigned int, linkedit_data_command const*, encryption_info_command const*, ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC10A6E: ImageLoaderMachO::instantiateFromFile(char const*, int, unsigned char const*, unsigned long long, unsigned long long, stat const&, ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC038C2: dyld::loadPhase6(int, stat const&, char const*, dyld::LoadContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC08468: dyld::loadPhase5(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC08188: dyld::loadPhase4(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC07EED: dyld::loadPhase3(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC07642: dyld::loadPhase1(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC0347A: dyld::loadPhase0(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC0315E: dyld::load(char const*, dyld::LoadContext const&) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC08705: dyld::libraryLocator(char const*, bool, char const*, ImageLoader::RPathChain const*) (in /usr/lib/dyld)
==18681== by 0x7FFF5FC0E85D: ImageLoader::recursiveLoadLibraries(ImageLoader::LinkContext const&, bool, ImageLoader::RPathChain const&) (in /usr/lib/dyld)
==18681==
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from ImageProcessingConfigurationService
[ RUN ] ImageProcessingConfigurationService.evaluateConfigurationFile
[ OK ] ImageProcessingConfigurationService.evaluateConfigurationFile (13 ms)
[----------] 1 test from ImageProcessingConfigurationService (28 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (114 ms total)
[ PASSED ] 1 test.
==18681==
==18681== HEAP SUMMARY:
==18681== in use at exit: 1,346,030 bytes in 1,453 blocks
==18681== total heap usage: 2,926 allocs, 1,473 frees, 3,045,052 bytes allocated
==18681==
==18681== LEAK SUMMARY:
==18681== definitely lost: 10,580 bytes in 137 blocks
==18681== indirectly lost: 10,032 bytes in 152 blocks
==18681== possibly lost: 9,568 bytes in 183 blocks
==18681== still reachable: 43,598 bytes in 520 blocks
==18681== suppressed: 1,272,252 bytes in 461 blocks
==18681== Rerun with --leak-check=full to see details of leaked memory
==18681==
==18681== For counts of detected and suppressed errors, rerun with: -v
==18681== Use --track-origins=yes to see where uninitialised values come from
==18681== ERROR SUMMARY: 36 errors from 4 contexts (suppressed: 0 from 0)
Compiler is clang++ Apple LLVM version 7.3.0 (clang-703.0.31), OS X El Capitan (10.11.1).
Anyone else has had an issue like that? It seems stuff works nontheless, but the error creates noise that I'd rather ignore, I'm not sure if I can fix the root cause.
The issue seems like a false positive reported by valgrind which I can ignore as it's not caused by code.
I tried (at the time of writing) the latest valgrind suppressions file for macOS which didn't work for me, the issue was still reported.
I let valgrind dump the suppressions needed to ignore this error, using a command like:
valgrind --leak-check=full --show-reachable=yes --error-limit=no --gen-suppressions=all --log-file=l.log ./image_test
And then used a tool to parse the log output (the awk script didn't work for me as it contained a syntax error, I used the perl version) into a suppressions file:
cat l.log | ./parse_valgrind_suppressions.pl > s.supp
Now running the test with the generated suppresions file ignores the memory leak:
valgrind --suppressions=./s.supp ./image_test
When I use oprofile tool for performance analysis, the result include many stats of stl function, ACE function and boost function, how can i exclude these libraries when use oprofile for statistics?
This is my result:
samples cum. samples % cum. % symbol name
13935 13935 15.8646 15.8646 std::less<unsigned int>::operator()(unsigned int const&, unsigned int const&) const
5552 19487 6.3208 22.1854 cache_result::decode(void*, unsigned long&, void const*, unsigned long)
5360 24847 6.1022 28.2876 cache::CWebCachePolicy::makexmlReply(cache::CCacheQueuedRequest*, iovec&, ACE_5_6_1::ACE_Message_Block*)
4661 29508 5.3064 33.5940 std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned int>, std::allocator<unsigned int> >::_S_key(std::_Rb_tree_node<unsigned int> const*)
4649 34157 5.2928 38.8868 cache::CWebCachePolicy::updateOneSummaryResult(cache::CCacheQueuedRequest*, char*, int, int&, int*, int*, int*, char (*) [20], int*, int, int)
4568 38725 5.2005 44.0873 std::_Identity<unsigned int>::operator()(unsigned int const&) const
4266 42991 4.8567 48.9441 std::_Rb_tree_const_iterator<unsigned int>::_Rb_tree_const_iterator(std::_Rb_tree_node<unsigned int> const*)
3843 46834 4.3751 53.3192 std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned int>, std::allocator<unsigned int> >::_S_value(std::_Rb_tree_node<unsigned int> const*)
3000 49834 3.4154 56.7346 std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned int>, std::allocator<unsigned int> >::end() const
The result above shows many stl functions, which I want to do is just take care of my own function, not the standard libraries.
I am using valkrie/valgrind on Mac OS 10.8 to find memory leaks in a small testcase command line tool.
While I have been able to locate many problems successfully before, valgrind right now presents the following error to me of which I can't seem to make sense:
==69195== Conditional jump or move depends on uninitialised value(s)
==69195== at 0x3F68CF: ??? (in /usr/lib/system/libxpc.dylib)
==69195== by 0x11AC2F: ??? (in /usr/lib/libSystem.B.dylib)
==69195== by 0x8FE13CD9: ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==69195== by 0x8FE13FDD: ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==69195== by 0x8FE10267: ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&) (in /usr/lib/dyld)
==69195== by 0x8FE101CB: ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&) (in /usr/lib/dyld)
==69195== by 0x8FE100B9: ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) (in /usr/lib/dyld)
==69195== by 0x8FE01DD8: dyld::initializeMainExecutable() (in /usr/lib/dyld)
==69195== by 0x8FE05ADA: dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) (in /usr/lib/dyld)
==69195== by 0x8FE01375: dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) (in /usr/lib/dyld)
==69195== by 0x8FE01076: _dyld_start (in /usr/lib/dyld)
Usually valgrind's error traces touch my own code before they descend into library/system calls,
but in this case the error seems to occur in "dyld::initializeMainExecutable()", which is in a system linker library outside of my control.
Where could I look to fix this - is there another way to make sense of it?
Cheers+thanks y