valgrind安装在./configure时出错 5C

./configure 出错
checking for a supported version of gcc... Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
no (applellvm-9.0.0)
configure: error: please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0
这是为什么??

1个回答

mkdir: cannot create directory `/usr/local/include/valgrind': Permission denied
应该是没有权限。
尝试make或者make install的时候加上sudo。
例如:
sudo make;
sudo make install

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Linux下执行./configure时报错cannot create executables

具体如图 已安装好gcc,g++,这怎么解决,求各位大神指点!急 ![图片说明](https://img-ask.csdn.net/upload/201608/17/1471400882_265270.jpg)

在Debian上通过pecl安装apcu失败

<div class="post-text" itemprop="text"> <p>On Debian, I have installed <code>php5</code>, <code>php5-dev</code>, <code>php-pear</code>.</p> <p>Then I try to install apcu, but I get this error. Any idea?</p> <pre><code># pecl install apcu Failed to download pecl/apcu within preferred state "stable", latest release is version 4.0.7, stability "beta", use "channel://pecl.php.net/apcu-4.0.7" to install install failed # pecl install channel://pecl.php.net/apcu-4.0.7 downloading apcu-4.0.7.tgz ... Starting to download apcu-4.0.7.tgz (118,670 bytes) ..........................done: 118,670 bytes 43 source files, building running: phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525 Enable full APC compatibility [yes] : yes Enable internal debugging in APCu [no] : building in /tmp/pear/temp/pear-build-root2kAfTA/apcu-4.0.7 running: /tmp/pear/temp/apcu/configure --enable-apc-bc=yes --enable-apcu-debug=no checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for a sed that does not truncate output... /bin/sed checking for cc... cc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ISO C89... none needed checking how to run the C preprocessor... cc -E checking for icc... no checking for suncc... no checking whether cc understands -c and -o together... yes checking for system library directory... lib checking if compiler supports -R... no checking if compiler supports -Wl,-rpath,... yes checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for PHP prefix... /usr checking for PHP includes... -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib checking for PHP extension directory... /usr/lib/php5/20100525 checking for PHP installed headers prefix... /usr/include/php5 checking if debug is enabled... no checking if zts is enabled... no checking for re2c... no configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. checking for gawk... no checking for nawk... nawk checking if nawk is broken... no checking whether to enable APCu support... yes, shared checking if APCu should provide APC full compatibility support... yes checking if APCu should be allowed to use rwlocks... yes checking if APCu should be built in debug mode... no checking if APCu should clear on SIGUSR1... no checking if APCu will use mmap or shm... mmap checking if APCu should utilize spinlocks before flocks... no configure: WARNING: APCu has access to native rwlocks checking for sigaction... yes checking for union semun... no checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking valgrind/memcheck.h usability... no checking valgrind/memcheck.h presence... no checking for valgrind/memcheck.h... no checking for shm_open in -lrt... yes checking whether to include code coverage symbols... no checking how to print strings... printf checking for a sed that does not truncate output... (cached) /bin/sed checking for fgrep... /bin/grep -F checking for ld used by cc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 1572864 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop checking for /usr/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for dlltool... no checking how to associate runtime and link libraries... printf %s checking for ar... ar checking for archiver @FILE support... @ checking for strip... strip checking for ranlib... ranlib checking for gawk... (cached) nawk checking command to parse /usr/bin/nm -B output from cc object... ok checking for sysroot... no checking for mt... mt checking if mt is a manifest tool... no checking for dlfcn.h... yes checking for objdir... .libs checking if cc supports -fno-rtti -fno-exceptions... no checking for cc option to produce PIC... -fPIC -DPIC checking if cc PIC flag -fPIC -DPIC works... yes checking if cc static flag -static works... yes checking if cc supports -c -o file.o... yes checking if cc supports -c -o file.o... (cached) yes checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no configure: creating ./config.status config.status: creating config.h config.status: executing libtool commands running: make sh: 1: make: not found ERROR: `make' failed </code></pre> <p><strong>EDIT:</strong> ops, I didn't have "make" installed (which is ridiculous, if pecl needs it it should be a dependency and have been installed automatically while installing the above packages) </p> <p>Anyway, now I get this error:</p> <pre><code>In file included from /tmp/pear/temp/apcu/apc.c:44:0: /usr/include/php5/ext/pcre/php_pcre.h:29:18: fatal error: pcre.h: No such file or directory compilation terminated. make: *** [apc.lo] Error 1 ERROR: `make' failed </code></pre> <p>Looks like another dependency is missing.</p> <p>Shouldn't these package manager be able to install all their dependencies automatically?</p> <p>Is there an easier way out of this than manually installing every single piece that turns out to be missing?</p> </div>

valgrind 调试错误提示信息 Bad permissions for mapped region at address 0x596

Valgrind 调试提示如下, Bad permissions for mapped region at address 0x596 这句怎么理解? 我很确定我没有使用未分配内存 ``` ==10268== Memcheck, a memory error detector ==10268== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==10268== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info ==10268== Command: ../bin/RecvBluetooth ==10268== ../bin/RecvBluetooth: error while loading shared libraries: liberrlog.so: cannot open shared object file: No such file or directory ==10268== Jump to the invalid address stated on the next line ==10268== at 0x596: ??? ==10268== by 0x400F1F9: _dl_signal_error (in /usr/lib64/ld-2.17.so) ==10268== by 0x400DE3D: _dl_map_object_deps (in /usr/lib64/ld-2.17.so) ==10268== by 0x4003625: dl_main (in /usr/lib64/ld-2.17.so) ==10268== by 0x4017537: _dl_sysdep_start (in /usr/lib64/ld-2.17.so) ==10268== by 0x4001BC0: _dl_start (in /usr/lib64/ld-2.17.so) ==10268== by 0x4001177: ??? (in /usr/lib64/ld-2.17.so) ==10268== Address 0x596 is not stack'd, malloc'd or (recently) free'd ==10268== ==10268== ==10268== Process terminating with default action of signal 11 (SIGSEGV) ==10268== Bad permissions for mapped region at address 0x596 ==10268== at 0x596: ??? ==10268== by 0x400F1F9: _dl_signal_error (in /usr/lib64/ld-2.17.so) ==10268== by 0x400DE3D: _dl_map_object_deps (in /usr/lib64/ld-2.17.so) ==10268== by 0x4003625: dl_main (in /usr/lib64/ld-2.17.so) ==10268== by 0x4017537: _dl_sysdep_start (in /usr/lib64/ld-2.17.so) ==10268== by 0x4001BC0: _dl_start (in /usr/lib64/ld-2.17.so) ==10268== by 0x4001177: ??? (in /usr/lib64/ld-2.17.so) ==10268== ==10268== HEAP SUMMARY: ==10268== in use at exit: 0 bytes in 0 blocks ==10268== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==10268== ==10268== All heap blocks were freed -- no leaks are possible ==10268== ==10268== For counts of detected and suppressed errors, rerun with: -v ==10268== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ```

c++ 用Valgrind检查时提示Memory Leaks

用Valgrind查内存问题 其中有一个变量是一个pointer的数组 对他重新赋值的时候会提示memory leaks ``` 1. int** m_data; // m_data内所有元素已经分配好空间并赋值 长度为len void resize(){ int** temp = new int* [10]; for(...){temp[]...} //循环给temp分配空间并赋值 for(int i = 0; i < len; i ++){ delete[] m_data[i]; } delete[] m_data; m_data = temp; } ``` 而如果我换另外一种写法就没有memory leaks ``` 2. void resize(){ int** temp = m_data; m_data = new int* [10]; for(...){m_data[]...} //循环给m_data分配空间并赋值 for(int i = 0; i < len; i ++){ delete[] temp[i]; } delete[] temp; } ``` m_data是成员变量并且在析构函数里delete了 想知道为什么第一种写法会memory leaks第二种不会

android平台使用valgrind分析内存,行号不正确

android 4.4.4,使用源码里自带的valgrind进行分析,自己写了个数组越界的demo。然后使用valgrind分析,结果发现定位的行号有问题。请教一下如何才能得到正确的行号。分析结果如下。 `==2687== Memcheck, a memory error detector ==2687== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. ==2687== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info ==2687== Command: /system/bin/app_process /system/bin --application --nice-name=com.lhkj.blurdemo com.android.internal.os.WrapperInit 37 18 android.app.ActivityThread ==2687== Parent PID: 2686 ==2687== ==2687== Warning: set address range perms: large range [0x6133000, 0x26133000) (noaccess) ==2687== Invalid read of size 4 ==2687== at 0x40053C8: ??? (in /system/bin/linker) ==2687== Address 0x374975e0 is 32 bytes inside a block of size 35 alloc'd ==2687== at 0x48993CC: malloc (in /system/lib/valgrind/vgpreload_memcheck-arm-linux.so) ==2687== by 0x60D6677: dvmCreateCstrFromString(StringObject const*) (in /system/lib/libdvm.so) ==2687== disInstr(thumb): unhandled instruction: 0x4771 0x5F43 ==2687== Mismatched free() / delete / delete [] ==2687== at 0x48972B4: operator delete[](void*) (in /system/lib/valgrind/vgpreload_memcheck-arm-linux.so) ==2687== by 0x60E714D: ??? (in /system/lib/libdvm.so) ==2687== Address 0x3c5ce740 is 0 bytes inside a block of size 188 alloc'd ==2687== at 0x48993CC: malloc (in /system/lib/valgrind/vgpreload_memcheck-arm-linux.so) ==2687== by 0x61059B9: dexReadAndVerifyClassData(unsigned char const**, unsigned char const*) (in /system/lib/libdvm.so) ==2687== ==2687== Conditional jump or move depends on uninitialised value(s) ==2687== at 0x4004D74: ??? (in /system/bin/linker) ==2687== by 0x400101D: _start (in /system/bin/linker) ==2687== Uninitialised value was created by a stack allocation ==2687== at 0x4AC959C: ??? (in /system/lib/libEGL.so) ==2687== ==2687== Conditional jump or move depends on uninitialised value(s) ==2687== at 0x482AC66: mmap (in /system/lib/libc.so) ==2687== Uninitialised value was created by a stack allocation ==2687== at 0x3E0BF9E8: ioctl_kgsl_device_getproperty (in /system/vendor/lib/libgsl.so) ==2687== ==2687== Syscall param mmap2(length) contains uninitialised byte(s) ==2687== at 0x483842C: __mmap2 (in /system/lib/libc.so) ==2687== Uninitialised value was created by a stack allocation ==2687== at 0x3E0BF9E8: ioctl_kgsl_device_getproperty (in /system/vendor/lib/libgsl.so) ==2687== ==2687== Syscall param mmap2(offset) contains uninitialised byte(s) ==2687== at 0x483842C: __mmap2 (in /system/lib/libc.so) ==2687== Uninitialised value was created by a stack allocation ==2687== at 0x3E0BF9E8: ioctl_kgsl_device_getproperty (in /system/vendor/lib/libgsl.so) ==2687== ==2687== Invalid read of size 4 ==2687== at 0x4004EE4: ??? (in /system/bin/linker) ==2687== by 0x400101D: _start (in /system/bin/linker) ==2687== Address 0x368aabf0 is 48 bytes inside a block of size 50 alloc'd ==2687== at 0x48993CC: malloc (in /system/lib/valgrind/vgpreload_memcheck-arm-linux.so) ==2687== by 0x60D0BC9: ??? (in /system/lib/libdvm.so) ==2687== ==2687== Conditional jump or move depends on uninitialised value(s) ==2687== at 0x3E0B8400: gsl_command_readtimestamp (in /system/vendor/lib/libgsl.so) ==2687== Uninitialised value was created by a stack allocation ==2687== at 0x3E0BF9E8: ioctl_kgsl_device_getproperty (in /system/vendor/lib/libgsl.so) ==2687== ==2687== Conditional jump or move depends on uninitialised value(s) ==2687== at 0x3E0B840C: gsl_command_readtimestamp (in /system/vendor/lib/libgsl.so) ==2687== Uninitialised value was created by a stack allocation ==2687== at 0x3E0BF9E8: ioctl_kgsl_device_getproperty (in /system/vendor/lib/libgsl.so) ==2687== ==2687== Syscall param socketcall.sendto(msg) points to uninitialised byte(s) ==2687== at 0x48392F4: sendto (in /system/lib/libc.so) ==2687== Address 0xbdafd72c is on thread 1's stack ==2687== Uninitialised value was created by a stack allocation ==2687== at 0x4B4FF66: android::InputConsumer::sendUnchainedFinishedSignal(unsigned int, bool) (in /system/lib/libinput.so) ==2687== `

sonarqube 分析C++代码遇到问题

我是在sonarqube中使用cppcheck插件来分析的。 步骤: 1、要先安装cppcheck工具。安装命令如下: make SRCDIR=build CFGDIR=/usr/bin/cfg HAVE_RULES=yes make install CFGDIR=/usr/bin/cfg 2、在需要分析的项目路径中执行“ cppcheck -j 1 --enable=all --xml ./src/* 1>cppcheck-result-1.xml 2>&1”生成一个xml文件 3、编辑sonar-project.properties配置文件,加入 sonar.cxx.cppcheck.reportPath=cppcheck-result-1.xml sonar.cxx.includeDirectories=/usr/include/ 4、最后执行sonar-runner 分析。 ![图片说明](https://img-ask.csdn.net/upload/201508/24/1440386059_527734.png) 但是我觉得使用cppcheck插件分析的结果不够好,请教一下各位高手,还有没有更好的解决方法。 另外 Valgrind /PC-lint/RATS /Vera++ 等插件要怎么使用?

valgrind嵌入式下使用问题

valgrind问题 我在嵌入式linux下使用valgrind时遇到这样的错误,请问各位大神:该如何解决啊? valgrind: mmap(0x120000000, 3760128) failed in UME with error 22 (Invalid argument). valgrind: this can be caused by executables with very large text, data or bss segments.

Golang中的内存泄漏

<div class="post-text" itemprop="text"> <p>Here is the code. In the golang main function, which in main.go</p> <pre><code>func main() { rgc.GetRgcService() } </code></pre> <p>where the <code>rgc</code> is in another golang file, named <code>mrgc.go</code>. The code inside is</p> <pre><code>package rgc func GetRgcService() (svc *RgcService, err error) {} </code></pre> <p>The function GetRgcService is a empty function.</p> <p>However, when I used <code>valgrind</code> to test the memory, I got the following output</p> <pre><code> ==58156== HEAP SUMMARY: ==58156== in use at exit: 1,152 bytes in 4 blocks ==58156== total heap usage: 9 allocs, 5 frees, 1,304 bytes allocated ==58156== 288 bytes in 1 blocks are possibly lost in loss record 4 of 4 ==58156== at 0x4A27F63: calloc (vg_replace_malloc.c:593) ==58156== by 0x4010DE1: allocate_dtv (in /home/opt/gcc-4.8.2.bpkg-r2/gcc-4.8.2.bpkg-r2/lib64/ld-2.18.so) ==58156== by 0x40114ED: _dl_allocate_tls (in /home/opt/gcc-4.8.2.bpkg-r2/gcc-4.8.2.bpkg-r2/lib64/ld-2.18.so) ==58156== by 0x4B36DE2: pthread_create@@GLIBC_2.2.5 (in /home/opt/gcc-4.8.2.bpkg-r2/gcc-4.8.2.bpkg-r2/lib64/libpthread-2.18.so) ==58156== by 0x4B2937: _cgo_sys_thread_start (gcc_linux_amd64.c:75) ==58156== by 0x45506C: runtime.asmcgocall (/home/map/.jumbo/lib/go/src/runtime/asm_amd64.s:612) ==58156== by 0x50619F: ??? (in /home/users/zhanghuaizhi/ttt.38) ==58156== by 0xC7FFFFFFFF: ??? ==58156== by 0xC820067FFF: ??? ==58156== by 0x42D69B: runtime.allocm (/home/map/.jumbo/lib/go/src/runtime/proc.go:1260) ==58156== by 0x42DD3A: runtime.newm (/home/map/.jumbo/lib/go/src/runtime/proc.go:1510) ==58156== by 0x42E071: runtime.startm (/home/map/.jumbo/lib/go/src/runtime/proc.go:1583) ==58156== ==58156== LEAK SUMMARY: ==58156== definitely lost: 0 bytes in 0 blocks ==58156== indirectly lost: 0 bytes in 0 blocks ==58156== possibly lost: 1,152 bytes in 4 blocks ==58156== still reachable: 0 bytes in 0 blocks ==58156== suppressed: 0 bytes in 0 blocks </code></pre> <p>How can I free these memory? Since I need to used this function to do a lot of process. It causes lots of memory leaks, which can not be freed</p> </div>

Centos6.5 使用curl时 用valgrind 检查内存泄露

测试源码如下 ``` #include "stdio.h" #include <iostream> #include <curl/curl.h> #include <openssl/crypto.h> #include <openssl/err.h> #include <openssl/evp.h> #include <openssl/conf.h> #include <openssl/ssl.h> #include <openssl/rand.h> #define LOG_STD(p) std::cout<<__FUNCTION__<<" "<<p<<"["<<__FILE__<<":"<<__LINE__<<"]"<<std::endl int main(int argc, char* argv[]) { LOG_STD("test--begin"); CURLcode code = curl_global_init(CURL_GLOBAL_SSL); if (code != CURLE_OK) { LOG_STD("curl_global_init fail"); } LOG_STD("test--version:"<<curl_version()); sk_SSL_COMP_free(SSL_COMP_get_compression_methods()); CRYPTO_cleanup_all_ex_data(); CONF_modules_free(); ERR_remove_state(0); CONF_modules_unload(1); ERR_free_strings(); ERR_remove_thread_state(NULL); EVP_cleanup(); curl_global_cleanup(); LOG_STD("test--begin"); } ``` 直接测试结果如下 ``` [root@localhost curl_test]# valgrind --leak-check=full ./a.out ==4897== Memcheck, a memory error detector ==4897== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==4897== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==4897== Command: ./a.out ==4897== main test--begin[Test.cpp:18] main test--version:libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2[Test.cpp:25] main test--begin[Test.cpp:36] ==4897== ==4897== HEAP SUMMARY: ==4897== in use at exit: 7,776 bytes in 78 blocks ==4897== total heap usage: 88 allocs, 10 frees, 8,891 bytes allocated ==4897== ==4897== LEAK SUMMARY: ==4897== definitely lost: 0 bytes in 0 blocks ==4897== indirectly lost: 0 bytes in 0 blocks ==4897== possibly lost: 0 bytes in 0 blocks ==4897== still reachable: 7,776 bytes in 78 blocks ==4897== suppressed: 0 bytes in 0 blocks ==4897== Reachable blocks (those to which a pointer was found) are not shown. ==4897== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==4897== ==4897== For counts of detected and suppressed errors, rerun with: -v ==4897== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4) ``` 更新curl版本后测试如下 ``` [root@localhost curl_test]# valgrind --leak-check=full --show-leak-kinds=all ./a.out ==4979== Memcheck, a memory error detector ==4979== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==4979== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==4979== Command: ./a.out ==4979== main test--begin[Test.cpp:18] main test--version:libcurl/7.55.1 OpenSSL/1.0.1e zlib/1.2.3 c-ares/1.13.0 libssh2/1.8.0 nghttp2/1.6.0[Test.cpp:25] main test--begin[Test.cpp:36] ==4979== ==4979== HEAP SUMMARY: ==4979== in use at exit: 416 bytes in 6 blocks ==4979== total heap usage: 4,206 allocs, 4,200 frees, 142,966 bytes allocated ==4979== ==4979== 24 bytes in 1 blocks are still reachable in loss record 1 of 6 ==4979== at 0x4A0728A: malloc (vg_replace_malloc.c:299) ==4979== by 0x301566AC2D: CRYPTO_malloc (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C5E5: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C6A8: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D650F: engine_free_util (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D6B8F: ENGINE_remove (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D6C74: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D63B5: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156E5A8F: sk_pop_free (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D638B: ENGINE_cleanup (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x4C82CDD: ??? (in /usr/lib64/libcurl.so.4.4.0) ==4979== by 0x4C85D31: ??? (in /usr/lib64/libcurl.so.4.4.0) ==4979== ==4979== 24 bytes in 1 blocks are still reachable in loss record 2 of 6 ==4979== at 0x4A0728A: malloc (vg_replace_malloc.c:299) ==4979== by 0x301566AC2D: CRYPTO_malloc (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156E6302: lh_insert (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C617: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C6A8: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D650F: engine_free_util (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D6B8F: ENGINE_remove (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D6C74: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D63B5: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156E5A8F: sk_pop_free (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D638B: ENGINE_cleanup (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x4C82CDD: ??? (in /usr/lib64/libcurl.so.4.4.0) ==4979== ==4979== 32 bytes in 1 blocks are still reachable in loss record 3 of 6 ==4979== at 0x4A0728A: malloc (vg_replace_malloc.c:299) ==4979== by 0x301566AC2D: CRYPTO_malloc (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156E5C9E: sk_new (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C5FB: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C6A8: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D650F: engine_free_util (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D6B8F: ENGINE_remove (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D6C74: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D63B5: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156E5A8F: sk_pop_free (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D638B: ENGINE_cleanup (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x4C82CDD: ??? (in /usr/lib64/libcurl.so.4.4.0) ==4979== ==4979== 32 bytes in 1 blocks are still reachable in loss record 4 of 6 ==4979== at 0x4A0728A: malloc (vg_replace_malloc.c:299) ==4979== by 0x301566AC2D: CRYPTO_malloc (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156E5CBC: sk_new (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C5FB: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C6A8: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D650F: engine_free_util (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D6B8F: ENGINE_remove (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D6C74: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D63B5: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156E5A8F: sk_pop_free (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D638B: ENGINE_cleanup (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x4C82CDD: ??? (in /usr/lib64/libcurl.so.4.4.0) ==4979== ==4979== 128 bytes in 1 blocks are still reachable in loss record 5 of 6 ==4979== at 0x4A0728A: malloc (vg_replace_malloc.c:299) ==4979== by 0x301566AC2D: CRYPTO_malloc (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156E6391: lh_new (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C524: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C674: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C6A8: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D650F: engine_free_util (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D6B8F: ENGINE_remove (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D6C74: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D63B5: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156E5A8F: sk_pop_free (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D638B: ENGINE_cleanup (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== ==4979== 176 bytes in 1 blocks are still reachable in loss record 6 of 6 ==4979== at 0x4A0728A: malloc (vg_replace_malloc.c:299) ==4979== by 0x301566AC2D: CRYPTO_malloc (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156E636F: lh_new (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C524: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C674: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x301566C6A8: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D650F: engine_free_util (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D6B8F: ENGINE_remove (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D6C74: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D63B5: ??? (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156E5A8F: sk_pop_free (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== by 0x30156D638B: ENGINE_cleanup (in /usr/lib64/libcrypto.so.1.0.1e) ==4979== ==4979== LEAK SUMMARY: ==4979== definitely lost: 0 bytes in 0 blocks ==4979== indirectly lost: 0 bytes in 0 blocks ==4979== possibly lost: 0 bytes in 0 blocks ==4979== still reachable: 416 bytes in 6 blocks ==4979== suppressed: 0 bytes in 0 blocks ==4979== ==4979== For counts of detected and suppressed errors, rerun with: -v ==4979== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4) ```

在Go程序中获取C代码堆栈跟踪

<div class="post-text" itemprop="text"> <p>I'm using the <a href="https://github.com/rana/ora" rel="nofollow noreferrer">rana/ora</a> oracle driver in my Go program to query some Oracle tables.</p> <p>The program somehow always gets SIGSEGV from a C library after running for a while and exits on segfault. It also gets a lot of query timeouts (<code>context deadline exceeded</code>) before it hits segfault error.</p> <p>I'm using the driver in a pretty standard way:</p> <pre><code>ctx, cancel := context.WithTimeout(context.Background(), 10*time.Seconds) defer cancel() rows, err := initialedDb.QueryContext(ctx, "sql_query") </code></pre> <p>The stack trace from the 1st Goroutine is:</p> <pre><code>fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x7fbb03e5d193] runtime stack: runtime.throw(0xa4a0a4, 0x2a) /usr/local/go/src/runtime/panic.go:596 +0x95 runtime.sigpanic() /usr/local/go/src/runtime/signal_unix.go:274 +0x2db goroutine 5230 [syscall, locked to thread]: runtime.cgocall(0x921850, 0xc421667348, 0xa495f1) /usr/local/go/src/runtime/cgocall.go:131 +0xe2 fp=0xc421667308 sp=0xc4216672c8 gopkg.in/rana/ora%2ev4._Cfunc_OCIAttrGet(0x2c92f08, 0x35, 0xc421cb8be4, 0xc421cb8be8, 0x5, 0x2b81930, 0xc400000000) gopkg.in/rana/ora.v4/_obj/_cgo_gotypes.go:347 +0x4d fp=0xc421667348 sp=0xc421667308 gopkg.in/rana/ora%2ev4.(*Rset).paramAttr.func1(0x2c92f08, 0xc400000035, 0xc421cb8be4, 0xc421cb8be8, 0x5, 0x2b81930, 0xf1ef01) /go/src/gopkg.in/rana/ora.v4/rset.go:970 +0xfc fp=0xc421667390 sp=0xc421667348 gopkg.in/rana/ora%2ev4.(*Rset).paramAttr(0xc4211f22d0, 0x2c92f08, 0xc421cb8be4, 0xc421cb8be8, 0xc400000005, 0x0, 0x0) /go/src/gopkg.in/rana/ora.v4/rset.go:976 +0x88 fp=0xc4216673e0 sp=0xc421667390 gopkg.in/rana/ora%2ev4.(*Rset).open(0xc4211f22d0, 0xc421358000, 0x7fbae405ed28, 0x0, 0x0) /go/src/gopkg.in/rana/ora.v4/rset.go:554 +0xd43 fp=0xc421667b98 sp=0xc4216673e0 gopkg.in/rana/ora%2ev4.(*Stmt).qryC(0xc421358000, 0xf1e940, 0xc421ace900, 0xc421cb8ad0, 0x1, 0x1, 0xc4211f22d0, 0x0, 0x0) /go/src/gopkg.in/rana/ora.v4/stmt.go:442 +0x3e0 fp=0xc421667f18 sp=0xc421667b98 gopkg.in/rana/ora%2ev4.(*DrvStmt).QueryContext.func1(0xc421b73260, 0xc420e789e8, 0xc420e789e0, 0xf1e940, 0xc421ace900, 0xc421cb8ad0, 0x1, 0x1) /go/src/gopkg.in/rana/ora.v4/drvStmt_go1_8.go:76 +0xa6 fp=0xc421667fa0 sp=0xc421667f18 runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc421667fa8 sp=0xc421667fa0 created by gopkg.in/rana/ora%2ev4.(*DrvStmt).QueryContext /go/src/gopkg.in/rana/ora.v4/drvStmt_go1_8.go:82 +0x30c </code></pre> <p>I checked my program many times and I don't think I'm causing any memory leaks, double frees or anything like that.</p> <p>I wonder how I can debug this since Go doesn't give me C's stack trace. Will Valgrind's Memcheck tool help?</p> </div>

编译安卓valgrind时报错gcc: error: unrecognized command line option ‘-marm’; did you mean ‘-mabm’?怎么处理?

使用的valgrind是valgrind-3.15.0,ndk是官网下载的android-ndk-r16b-linux-x86_64 按照网上的教程编写了脚本。 ![图片说明](https://img-ask.csdn.net/upload/202005/18/1589803097_23591.png) 结果如下 ![图片说明](https://img-ask.csdn.net/upload/202005/18/1589803171_228057.png) 然后执行make命令出错gcc: error: unrecognized command line option ‘-marm’; did you mean ‘-mabm’? ![图片说明](https://img-ask.csdn.net/upload/202005/18/1589803447_627302.png) 请问这个错误该怎么处理?

Php Kcachegrind安装工作流程

<div class="post-text" itemprop="text"> <p>Mac environment (php v5.3.3).I need to analyze xdebug profiling logs.Reading around I understood that I should use Kcachegrind.I'm following a DevZone tutorial <a href="http://devzone.zend.com/article/2899" rel="nofollow">Profiling PHP applications with Xdebug</a>.I got stuck at two specific points:</p> <pre><code>If possible, use your system's packet manager to install the KCachegrind package. KCachegrind uses GraphViz to draw the call graphs, so you must also install the GraphViz package if your packet manager does not automatically install it as a required dependecy. </code></pre> <p>and</p> <pre><code>As you can see, the path to the KDE libraries on your system is required. To configure the KCachegrind sources. If you are not sure where the KDE libraries are located on your system, use [..] </code></pre> <ul> <li><p>What's a system's packet manager?</p></li> <li><p>What's KDE libraries and how do I get them installed?</p></li> </ul> <p>I would also know if I should use Kcachegrind 0.4.6 or 0.10.1 (full Valgrind package) or there are other profiling tools that you want to suggest.</p> <p>thanks</p> <p>Luca </p> </div>

关于linux 红帽6.4安装使用valgrind

我想用它检查内存泄露 但是它要求的glibc版本为2.2以上,而我当前的版本为2.0, 请问,改怎么弄 据说不推荐升级glib

如何正确地将参数传递给syscall(git)?

<div class="post-text" itemprop="text"> <p>I am trying to clone a git repository by calling git via <code>syscall</code>. (I know there is <a href="https://github.com/libgit2/git2go" rel="nofollow">git2go</a> but that's not what I want. I definitely want to do a <code>syscall</code>)</p> <pre><code>git, lookErr := exec.LookPath("git") if lookErr != nil { fmt.Fprintf(os.Stderr, "%s ", lookErr) os.Exit(126) } args := []string{"clone", "http://github.com/some/repo.git"} var env = os.Environ() execErr := syscall.Exec(git, args, env) if execErr != nil { panic(execErr) } </code></pre> <p>So what I want to execute is <code>git clone http://github.com/some/repo.git</code> and executing this manually works just fine. But when I run it in go like in the code snippet above, git fails with this:</p> <blockquote> <p>git: '<a href="http://github.com/some/repo.git" rel="nofollow">http://github.com/some/repo.git</a>' is not a git command. See 'git --help'.</p> </blockquote> <p>Why would git interpret the 2nd argument as another command? It is supposed to be the remote <code>&lt;repo&gt;</code> URL, <code>git clone [options] [--] &lt;repo&gt; [&lt;dir&gt;]</code>.</p> <p>How do I pass the arguments correctly so git has the expected behavior?</p> </div>

致命错误:Cgo中的写屏障中的指针错误

<div class="post-text" itemprop="text"> <p>My program crashed 1 time within 1000 times. Here is the debug information and stack:</p> <pre><code>437 new map 0 -603977536 address&amp;{[&lt;nil&gt; 0x7fafdc0009f0 0x7fafdc000b00]} 0x7fafdc0008c0 0x7fafdc0008c8 0x7fafdc0008d0 &amp;{1 0 0x7fafdc000900} &amp;{1 0 0x7fafdc000a10} &amp;{1 0 0x7fafdc000b20} rgc map finish 438 new map 0 -603977536 address&amp;{[&lt;nil&gt; 0x7fafdc0009f0 0x7fafdc000b00]} 0x7fafdc0008c0 0x7fafdc0008c8 0x7fafdc0008d0 &amp;{1 0 0x7fafdc000900} &amp;{1 0 0x7fafdc000a10} &amp;{1 0 0x7fafdc000b20} rgc map finish 439 new map 0 -603977536 address&amp;{[&lt;nil&gt; 0x7fafdc0009f0 0x7fafdc000b00]} 0x7fafdc0008c0 0x7fafdc0008c8 0x7fafdc0008d0 &amp;{1 0 0x7fafdc000900} &amp;{1 0 0x7fafdc000a10} &amp;{1 0 0x7fafdc000b20} rgc map finish 440 new map 0 -603977536 address&amp;{[&lt;nil&gt; 0x7fafdc0009f0 0x7fafdc000b00]} 0x7fafdc0008c0 0x7fafdc0008c8 0x7fafdc0008d0 &amp;{1 0 0x7fafdc000900} &amp;{1 0 0x7fafdc000a10} &amp;{1 0 0x7fafdc000b20} rgc map finish 441 new map 0 -536868672 fatal error: bad pointer in write barrier runtime stack: runtime.throw(0x53d200, 0x1c) /home/map/.jumbo/lib/go/src/runtime/panic.go:530 +0x90 runtime.writebarrierptr_nostore.func1() /home/map/.jumbo/lib/go/src/runtime/mbarrier.go:157 +0x2c runtime.systemstack(0xc820024a00) /home/map/.jumbo/lib/go/src/runtime/asm_amd64.s:291 +0x79 runtime.mstart() /home/map/.jumbo/lib/go/src/runtime/proc.go:1048 goroutine 1 [running]: runtime.systemstack_switch() /home/map/.jumbo/lib/go/src/runtime/asm_amd64.s:245 fp=0xc82009ebd8 sp=0xc82009ebd0 runtime.writebarrierptr_nostore(0xc82030e010, 0x20) /home/map/.jumbo/lib/go/src/runtime/mbarrier.go:157 +0x83 fp=0xc82009ebf0 sp=0xc82009ebd8 runtime.heapBitsBulkBarrier(0xc82030e000, 0x18) /home/map/.jumbo/lib/go/src/runtime/mbitmap.go:437 +0x201 fp=0xc82009ec88 sp=0xc82009ebf0 runtime.typedmemmove(0x4fa700, 0xc82030e000, 0x7fafe00008c0) /home/map/.jumbo/lib/go/src/runtime/mbarrier.go:197 +0x98 fp=0xc82009ecb8 sp=0xc82009ec88 reflect.typedmemmove(0x4fa700, 0xc82030e000, 0x7fafe00008c0) /home/map/.jumbo/lib/go/src/runtime/mbarrier.go:202 +0x35 fp=0xc82009ecd8 sp=0xc82009ecb8 reflect.packEface(0x4fa700, 0x7fafe00008c0, 0x199, 0x0, 0x0) /home/map/.jumbo/lib/go/src/reflect/value.go:113 +0x120 fp=0xc82009ed48 sp=0xc82009ecd8 reflect.valueInterface(0x4fa700, 0x7fafe00008c0, 0x199, 0x1, 0x0, 0x0) /home/map/.jumbo/lib/go/src/reflect/value.go:938 +0x1ec fp=0xc82009eda0 sp=0xc82009ed48 reflect.Value.Interface(0x4fa700, 0x7fafe00008c0, 0x199, 0x0, 0x0) /home/map/.jumbo/lib/go/src/reflect/value.go:908 +0x48 fp=0xc82009edd8 sp=0xc82009eda0 fmt.(*pp).printValue(0xc82040b380, 0x4fa700, 0x7fafe00008c0, 0x199, 0x7faf00000076, 0x1, 0x0) /home/map/.jumbo/lib/go/src/fmt/print.go:842 +0x372 fp=0xc82009eec8 sp=0xc82009edd8 fmt.(*pp).printReflectValue(0xc82040b380, 0x4cc980, 0x7fafe00008c0, 0x16, 0x76, 0x0, 0xc82001cd00) /home/map/.jumbo/lib/go/src/fmt/print.go:1009 +0x351e fp=0xc82009f680 sp=0xc82009eec8 fmt.(*pp).printArg(0xc82040b380, 0x4cc980, 0x7fafe00008c0, 0x76, 0x0, 0xc82009f800) /home/map/.jumbo/lib/go/src/fmt/print.go:810 +0x540 fp=0xc82009f808 sp=0xc82009f680 fmt.(*pp).doPrint(0xc82040b380, 0xc82009fdf8, 0x2, 0x2, 0x400000) /home/map/.jumbo/lib/go/src/fmt/print.go:1273 +0x24d fp=0xc82009f908 sp=0xc82009f808 fmt.Fprint(0x7faff5a401c0, 0xc820036010, 0xc82009fdf8, 0x2, 0x2, 0x40d75e, 0x0, 0x0) /home/map/.jumbo/lib/go/src/fmt/print.go:222 +0x67 fp=0xc82009f950 sp=0xc82009f908 fmt.Print(0xc82009fdf8, 0x2, 0x2, 0x4d6ac0, 0x0, 0x0) /home/map/.jumbo/lib/go/src/fmt/print.go:232 +0x73 fp=0xc82009f9a8 sp=0xc82009f950 services/newrgc.GetRgcService(0x54cb60, 0x49, 0xc8200aa330, 0x0, 0x0) /home/map/zhanghuaizhi/tmpwork/2/nbserver/src/services/newrgc/mrgc.go:78 +0x390 fp=0xc82009fea0 sp=0xc82009f9a8 main.main() /home/map/zhanghuaizhi/tmpwork/2/nbserver/src/services/newrgc/test/ttt.go:219 +0x163 fp=0xc82009ff40 sp=0xc82009fea0 runtime.main() /home/map/.jumbo/lib/go/src/runtime/proc.go:188 +0x2b0 fp=0xc82009ff90 sp=0xc82009ff40 runtime.goexit() /home/map/.jumbo/lib/go/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc82009ff98 sp=0xc82009ff90 goroutine 17 [syscall, locked to thread]: runtime.goexit() /home/map/.jumbo/lib/go/src/runtime/asm_amd64.s:1998 +0x1 </code></pre> <p>The deug information is before the stack log. <code>437</code> means the 437th loop, <code>new map 0 -603977536</code> is printed in C Code(<code>NewRgcMap</code>, the details can be found in the following content), the next two lines <code>address&amp;{[&lt;nil&gt; 0x7fafdc0009f0 0x7fafdc000b00]} 0x7fafdc0008c0 0x7fafdc0008c8 0x7fafdc0008d0 &amp;{1 0 0x7fafdc000900} &amp;{1 0 0x7fafdc000a10} &amp;{1 0 0x7fafdc000b20}</code> is printed in Go Code(GO code line 78 and 80).</p> <p>From the stack information, we can find that the error occurs in line 78. Now here is the Go code(mrgc.go)</p> <pre><code>30 type RgcService struct { 31 maps *C.struct_CRgcMap 32 } 74 func GetRgcService(cfgFile string) (svc *RgcService, err error) { 75 svc = new(RgcService) 76 // Init the skip list 77 C.NewRgcMap(&amp;svc.maps) 78 fmt.Print("address", svc.maps) 79 //fmt.Println("\t", svc.maps.sl[0], svc.maps.sl[1], svc.maps.sl[2]) 80 fmt.Println("\t", &amp;svc.maps.sl[0], &amp;svc.maps.sl[1], &amp;svc.maps.sl[2]) 81 C.skiplist_init(unsafe.Pointer(&amp;svc.maps.sl[0])) 82 C.skiplist_init(unsafe.Pointer(&amp;svc.maps.sl[1])) 83 C.skiplist_init(unsafe.Pointer(&amp;svc.maps.sl[2])) 84 fmt.Println("\t", svc.maps.sl[0], svc.maps.sl[1], svc.maps.sl[2]) </code></pre> <p>So, I probably guess the error happens because of the failure of <code>C.NewRgcMap(&amp;svc.maps)</code>. However, in my c code, the funciotn <code>NewRgcMap</code> is:</p> <pre><code>39 void NewRgcMap(CRgcMap** rgcmap) { 40 *rgcmap = NULL; 41 printf("new map %d\t", *rgcmap); 42 *rgcmap = (CRgcMap*)malloc(sizeof(CRgcMap)); 43 printf("%d ", *rgcmap); 44 while(*rgcmap == NULL) { 45 *rgcmap = (CRgcMap*)malloc(sizeof(CRgcMap)); 46 } </code></pre> <p>which means the <code>rgcmap</code> must be allocated correctly.</p> <p>Another point is, from my debug information, I found that the program crashed when the log <code>new map 0 -603977536</code> is changed to <code>new map -536868672</code> at the first time. In more details, the debug log is exactly the same when the program crashed. <code>new map 0 xxxxx1</code> shows a number of time, then when it changed to <code>new map 0 xxxxx2</code>, it MAY crashes(most of the time, it will not)</p> <p>How to explain this crash? Moreover, I have used <code>valgrind</code> to test C code(Following is my C test codes)</p> <pre><code>int main() { CRgcMap map; int num = 0; for(num = 0; num &lt; 10000; num++) { skiplist_init(&amp;map.sl[0]); skiplist_init(&amp;map.sl[1]); skiplist_init(&amp;map.sl[2]); int i = 0; for(i = 0; i &lt; 100; i++) { skiplist_insert(map.sl[0], i, i); skiplist_insert(map.sl[1], i, i); //skiplist_insert(map.sl[2], i, i); } skiplist_test(map.sl[0]); skiplist_test(map.sl[1]); skiplist_test(map.sl[2]); } } </code></pre> <p>The report of <code>valgrind</code> shows that there is no memory leaks and everything is okay. But why it MAY crashes when using Golang? Is there anything related Go's GC? Or the address allocated by C is out of the space of Golang?</p> </div>

这个是什么情况,有人帮帮我吗

This time, you need to create tow function: void Assign(char * & str, int & length); According to the length, allocate memory to str. void AddTwo(string & res, char & str1, char & str2); Add str1 and str2, then assign the result to the res. More importantly, you need to handle str1 and str2 to guarantee that there would not happen memory problem. Sample input: 4 abcd 5 efghi Sample ouput: abcd efghi abcdefghi my code #ifndef EasyStr #define EasyStr #include <iostream> using std::cin; using std::string; void Assign(char * &, int &); void AddTwo(string &, char * &, char * &); #endif #include"EasyString.hpp" #include<string> #include<cstring> #include<iostream> using namespace std; void Assign(char *& str,int& length){ str = new char[length]; } void AddTwo(string & res , char *& str1,char*& str2){ res.assign(str1); res += str2; } #include <iostream> #include "EasyString.hpp" using namespace std; int main() { int length; char* str0 = NULL, * str1= NULL; cin >> length; Assign(str0, length); cin >> length; Assign(str1, length); cin >> str0 >> str1; cout << str0 << endl << str1 << endl; string res = ""; AddTwo(res, str0, str1); cout << res << endl; } 结果,评测 [1] Error : InvalidWrite obj: /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char> >(std::basic_istream<char, std::char_traits<char> >&, char*) [2] Error : InvalidWrite obj: /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char> >(std::basic_istream<char, std::char_traits<char> >&, char*) [3] Error : InvalidRead obj: /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so strlen [4] Error : InvalidRead obj: /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so strlen [5] Error : InvalidRead obj: /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so strlen [6] Error : InvalidRead obj: /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so strlen [7] Error : Leak_DefinitelyLost obj: /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so operator new[](unsigned long) [8] Error : Leak_DefinitelyLost obj: /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so operator new[](unsigned long)

内存泄漏???求高人

客户端代码,重点就是析构函数中的free。为什么一free就提示内存泄漏。 后面有valgrind内存分析。说是地址不可用??求高人解答,到底出错在哪?? NtClient::NtClient() { memset(&m_servAddr, 0, sizeof(struct sockaddr_in)); m_servAddr.sin_family = AF_INET; m_servAddr.sin_port = htons(6606); inet_aton("127.0.0.1", reinterpret_cast<in_addr*>(&m_servAddr.sin_addr.s_addr)); int m_clientFd = -1; m_receBuffer = (char*)malloc(100); printf("m_receBuffer = %p\n", m_receBuffer); } NtClient::~NtClient() { printf("m_receBuffer = %p\n", m_receBuffer); free(m_receBuffer2); //打开就泄漏,关闭没问题 m_receBuffer = NULL; } int NtClient::start() { int iRet = -1; //1.socket创建 int m_clientFd = socket(AF_INET, SOCK_STREAM, 0); if(m_clientFd < 0) { printf("Socket init error!\n"); return -1; } //2.connect iRet = connect(m_clientFd, (struct sockaddr*)&m_servAddr, sizeof(m_servAddr)); if(iRet < 0) { printf("%s---", strerror(errno)); printf("Connect error!\n"); return -1; } //3.recv||send iRet = recv(m_clientFd, m_receBuffer, 100*sizeof(m_receBuffer), 0); if(iRet < 0) { printf("Recv error!\n"); return -1; } else { printf("%s---", strerror(errno)); printf("recvNum=%d, recvData= %s\n", iRet, m_receBuffer); } //4.close //close(m_clientFd); return 0; } pcm@ubuntu:~/Desktop/cs1$ valgrind --tool=memcheck --leak-check=full ./a.out ==5430== Memcheck, a memory error detector ==5430== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==5430== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==5430== Command: ./a.out ==5430== m_receBuffer = 0x5a02040 ==5430== Syscall param socketcall.recvfrom(buf) points to unaddressable byte(s) ==5430== at 0x543C2C2: recv (recv.c:30) ==5430== by 0x4011AD: NtClient::start() (in /home/pcm/Desktop/cs1/a.out) ==5430== by 0x400C83: main (in /home/pcm/Desktop/cs1/a.out) ==5430== Address 0x5a020a4 is 0 bytes after a block of size 100 alloc'd ==5430== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==5430== by 0x401092: NtClient::NtClient() (in /home/pcm/Desktop/cs1/a.out) ==5430== by 0x400C77: main (in /home/pcm/Desktop/cs1/a.out) ==5430== Success---recvNum=400, recvData= Service_return_ok! program! m_receBuffer = 0x5a02040 ==5430== ==5430== HEAP SUMMARY: ==5430== in use at exit: 0 bytes in 0 blocks ==5430== total heap usage: 1 allocs, 1 frees, 100 bytes allocated ==5430== ==5430== All heap blocks were freed -- no leaks are possible ==5430== ==5430== For counts of detected and suppressed errors, rerun with: -v ==5430== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 2) pcm@ubuntu:~/Desktop/cs1$

Symfony单元测试和过多的内存泄漏?

<div class="post-text" itemprop="text"> <p>We're currently having issues with memory leaks when using unit tests with Symfony 1.x to the magnitude of a decent number of tests eating 512MB of memory.</p> <p>Currently we've tried: </p> <ul> <li>Using a phpunit plugin</li> <li>Using lime</li> <li>Restricting the tests to a few sfPropelData loads + functional tests repeated a few times</li> <li>Switching to PHP 5.3.3 to handle circular references</li> <li>Inspecting memory usage xdebug which didn't give much insight</li> </ul> <p>Soon we'll be trying:</p> <ul> <li>Only the functional tests</li> <li>Replacing sfPropelData instead loading plain SQL files</li> <li>Only functional tests without any ORM calls</li> <li>Valgrind?</li> </ul> <p>I'm thinking maybe the static variables within symfony aren't getting cleaned up or the PDO layer is itself leaking memory. Of course, the last option is to figure out a way to run a suite of tests in its own process.</p> <p>We're progressing through the areas it could be in and I don't expect anyone to actually help us work out the details but I'm just throwing this question out there to see if anyone has experienced this and where they found the leak to be or what they did to get around this.</p> <p>Also, any input on other tools that can assist, like valgrind?</p> </div>

php Web应用程序的服务器端性能测试

<div class="post-text" itemprop="text"> <p>Before I get marked as dupe of articles like:</p> <pre><code>[http://stackoverflow.com/questions/635123/what-is-a-good-tool-or-site-to-use-to-performance-test-a-web-page-site][1] </code></pre> <p>Most of the answers on pages like that indicate performance testing of the html, using firebug, YSlow and so on. Loadrunner is cited, which is good, but what I'd like is a set of tools for performance testing the php itself to identify bottlenecks in the code.</p> <p><em>It's a LAMP setup.</em></p> <p>So, maybe:</p> <ul> <li>Code coverage testing</li> <li>Lint for php?</li> <li>Something like valgrind for c, but for php</li> <li>any other tool to really hammer the php code and look for flaws or inefficiencies</li> </ul> <p>Currently the best one I've found for it may be JMeter, but I'm only just starting to explore it.</p> <p>All suggestions appreciated!</p> </div>

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Linux面试题(2020最新版)

文章目录Linux 概述什么是LinuxUnix和Linux有什么区别?什么是 Linux 内核?Linux的基本组件是什么?Linux 的体系结构BASH和DOS之间的基本区别是什么?Linux 开机启动过程?Linux系统缺省的运行级别?Linux 使用的进程间通信方式?Linux 有哪些系统日志文件?Linux系统安装多个桌面环境有帮助吗?什么是交换空间?什么是root帐户什么是LILO?什...

Linux命令学习神器!命令看不懂直接给你解释!

大家都知道,Linux 系统有非常多的命令,而且每个命令又有非常多的用法,想要全部记住所有命令的所有用法,恐怕是一件不可能完成的任务。 一般情况下,我们学习一个命令时,要么直接百度去搜索它的用法,要么就直接用 man 命令去查看守冗长的帮助手册。这两个都可以实现我们的目标,但有没有更简便的方式呢? 答案是必须有的!今天给大家推荐一款有趣而实用学习神器 — kmdr,让你解锁 Linux 学习新姿势...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

史上最全的 python 基础知识汇总篇,没有比这再全面的了,建议收藏

网友们有福了,小编终于把基础篇的内容全部涉略了一遍,这是一篇关于基础知识的汇总的文章,请朋友们收下,不用客气,不过文章篇幅肯能会有点长,耐心阅读吧爬虫(七十)多进程multiproces...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

85后蒋凡:28岁实现财务自由、34岁成为阿里万亿电商帝国双掌门,他的人生底层逻辑是什么?...

蒋凡是何许人也? 2017年12月27日,在入职4年时间里,蒋凡开挂般坐上了淘宝总裁位置。 为此,时任阿里CEO张勇在任命书中力赞: 蒋凡加入阿里,始终保持创业者的冲劲,有敏锐的...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

新一代神器STM32CubeMonitor介绍、下载、安装和使用教程

关注、星标公众号,不错过精彩内容作者:黄工公众号:strongerHuang最近ST官网悄悄新上线了一款比较强大的工具:STM32CubeMonitor V1.0.0。经过我研究和使用之...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

大学一路走来,学习互联网全靠这几个网站,最终拿下了一把offer

大佬原来都是这样炼成的

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

什么时候跳槽,为什么离职,你想好了么?

都是出来打工的,多为自己着想

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你期望月薪4万,出门右拐,不送,这几个点,你也就是个初级的水平

先来看几个问题通过注解的方式注入依赖对象,介绍一下你知道的几种方式@Autowired和@Resource有何区别说一下@Autowired查找候选者的...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

立即提问
相关内容推荐