- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
出于某种原因,我的 valgrind 没有打印行号和发生错误的文件。这发生在 Linux Ubuntu 16.04.4 发行版中。
我是这样测试的:
/tmp/a.c:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char **argv)
{
char *buf = malloc(10);
strcpy(buf, argv[1]);
return 0;
}
我用以下命令执行了这一切:cd/tmp && gcc a.c -o hello -fno-stack-protector -fno-builtin -g && valgrind ./hello
$ cd /tmp && gcc a.c -o hello -fno-stack-protector -fno-builtin -g && valgrind ./hello ./hello
==23422== Memcheck, a memory error detector
==23422== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==23422== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==23422== Command: ./hello
==23422==
==23422== Invalid read of size 1
==23422== at 0x4C31047: strcpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23422== by 0x40119C: ??? (in /tmp/hello)
==23422== by 0x4E5A82F: (below main) (libc-start.c:291)
==23422== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==23422==
==23422==
==23422== Process terminating with default action of signal 11 (SIGSEGV)
==23422== Access not within mapped region at address 0x0
==23422== at 0x4C31047: strcpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23422== by 0x40119C: ??? (in /tmp/hello)
==23422== by 0x4E5A82F: (below main) (libc-start.c:291)
==23422== If you believe this happened as a result of a stack
==23422== overflow in your program's main thread (unlikely but
==23422== possible), you can try to increase the size of the
==23422== main thread stack using the --main-stacksize= flag.
==23422== The main thread stack size used in this run was 8388608.
==23422==
==23422== HEAP SUMMARY:
==23422== in use at exit: 10 bytes in 1 blocks
==23422== total heap usage: 1 allocs, 0 frees, 10 bytes allocated
==23422==
==23422== LEAK SUMMARY:
==23422== definitely lost: 0 bytes in 0 blocks
==23422== indirectly lost: 0 bytes in 0 blocks
==23422== possibly lost: 0 bytes in 0 blocks
==23422== still reachable: 10 bytes in 1 blocks
==23422== suppressed: 0 bytes in 0 blocks
==23422== Rerun with --leak-check=full to see details of leaked memory
==23422==
==23422== For counts of detected and suppressed errors, rerun with: -v
==23422== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)
GCC 版本:gcc 版本 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
Valgrind 版本:valgrind-3.11.0
我也尝试下载并编译最新的 valgrind 版本 (valgrind-3.13.0
),但以同样的问题结束。
编辑:
带有完整日志的输出:
$ valgrind -v --leak-check=full /tmp/a.out
==17717== Memcheck, a memory error detector
==17717== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==17717== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==17717== Command: /tmp/a.out
==17717==
--17717-- Valgrind options:
--17717-- -v
--17717-- --leak-check=full
--17717-- Contents of /proc/version:
--17717-- Linux version 4.4.0-119-generic (buildd@lcy01-amd64-013) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9) ) #143-Ubuntu SMP Mon Apr 2 16:08:24 UTC 2018
--17717--
--17717-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-rdtscp-sse3-avx
--17717-- Page sizes: currently 4096, max supported 4096
--17717-- Valgrind library directory: /usr/lib/valgrind
--17717-- Reading syms from /tmp/a.out
--17717-- ELF section outside all mapped regions
--17717-- Reading syms from /lib/x86_64-linux-gnu/ld-2.23.so
--17717-- Considering /lib/x86_64-linux-gnu/ld-2.23.so ..
--17717-- .. CRC mismatch (computed aa979a42 wanted 9019bbb7)
--17717-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so ..
--17717-- .. CRC is valid
--17717-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux
--17717-- Considering /usr/lib/valgrind/memcheck-amd64-linux ..
--17717-- .. CRC mismatch (computed eea41ea9 wanted 2009db78)
--17717-- object doesn't have a symbol table
--17717-- object doesn't have a dynamic symbol table
--17717-- Scheduler: using generic scheduler lock implementation.
--17717-- Reading suppressions file: /usr/lib/valgrind/default.supp
==17717== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-17717-by-rajiska-on-???
==17717== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-17717-by-rajiska-on-???
==17717== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-17717-by-rajiska-on-???
==17717==
==17717== TO CONTROL THIS PROCESS USING vgdb (which you probably
==17717== don't want to do, unless you know exactly what you're doing,
==17717== or are doing some strange experiment):
==17717== /usr/lib/valgrind/../../bin/vgdb --pid=17717 ...command...
==17717==
==17717== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==17717== /path/to/gdb /tmp/a.out
==17717== and then give GDB the following command
==17717== target remote | /usr/lib/valgrind/../../bin/vgdb --pid=17717
==17717== --pid is optional if only one valgrind process is running
==17717==
--17717-- REDIR: 0x401cfd0 (ld-linux-x86-64.so.2:strlen) redirected to 0x3809e181 (???)
--17717-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so
--17717-- Considering /usr/lib/valgrind/vgpreload_core-amd64-linux.so ..
--17717-- .. CRC mismatch (computed 2567ccf6 wanted 49420590)
--17717-- object doesn't have a symbol table
--17717-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so
--17717-- Considering /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so ..
--17717-- .. CRC mismatch (computed 0e27c9a8 wanted ac585421)
--17717-- object doesn't have a symbol table
==17717== WARNING: new redirection conflicts with existing -- ignoring it
--17717-- old: 0x0401cfd0 (strlen ) R-> (0000.0) 0x3809e181 ???
--17717-- new: 0x0401cfd0 (strlen ) R-> (2007.0) 0x04c31020 strlen
--17717-- REDIR: 0x401b920 (ld-linux-x86-64.so.2:index) redirected to 0x4c30bc0 (index)
--17717-- REDIR: 0x401bb40 (ld-linux-x86-64.so.2:strcmp) redirected to 0x4c320d0 (strcmp)
--17717-- REDIR: 0x401dd30 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4c35270 (mempcpy)
--17717-- Reading syms from /lib/x86_64-linux-gnu/libc-2.23.so
--17717-- Considering /lib/x86_64-linux-gnu/libc-2.23.so ..
--17717-- .. CRC mismatch (computed 7a8ee3e4 wanted a5190ac4)
--17717-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so ..
--17717-- .. CRC is valid
--17717-- REDIR: 0x4ec9a00 (libc.so.6:strcasecmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--17717-- REDIR: 0x4ec5280 (libc.so.6:strcspn) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--17717-- REDIR: 0x4ecbcf0 (libc.so.6:strncasecmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--17717-- REDIR: 0x4ec76f0 (libc.so.6:strpbrk) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--17717-- REDIR: 0x4ec7a80 (libc.so.6:strspn) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--17717-- REDIR: 0x4ec914b (libc.so.6:memcpy@GLIBC_2.2.5) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--17717-- REDIR: 0x4ec7400 (libc.so.6:rindex) redirected to 0x4c308a0 (rindex)
--17717-- REDIR: 0x4ebe130 (libc.so.6:malloc) redirected to 0x4c2db20 (malloc)
--17717-- REDIR: 0x4ec5160 (libc.so.6:strcpy) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--17717-- REDIR: 0x4edf9d0 (libc.so.6:__strcpy_sse2_unaligned) redirected to 0x4c31040 (strcpy)
==17717== Invalid read of size 1
==17717== at 0x4C31047: strcpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17717== by 0x40119C: ??? (in /tmp/a.out)
==17717== by 0x4E5A82F: (below main) (libc-start.c:291)
==17717== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==17717==
==17717==
==17717== Process terminating with default action of signal 11 (SIGSEGV)
==17717== Access not within mapped region at address 0x0
==17717== at 0x4C31047: strcpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17717== by 0x40119C: ??? (in /tmp/a.out)
==17717== by 0x4E5A82F: (below main) (libc-start.c:291)
==17717== If you believe this happened as a result of a stack
==17717== overflow in your program's main thread (unlikely but
==17717== possible), you can try to increase the size of the
==17717== main thread stack using the --main-stacksize= flag.
==17717== The main thread stack size used in this run was 8388608.
--17717-- REDIR: 0x4ebe4f0 (libc.so.6:free) redirected to 0x4c2ed80 (free)
==17717==
==17717== HEAP SUMMARY:
==17717== in use at exit: 10 bytes in 1 blocks
==17717== total heap usage: 1 allocs, 0 frees, 10 bytes allocated
==17717==
==17717== Searching for pointers to 1 not-freed blocks
==17717== Checked 62,704 bytes
==17717==
==17717== LEAK SUMMARY:
==17717== definitely lost: 0 bytes in 0 blocks
==17717== indirectly lost: 0 bytes in 0 blocks
==17717== possibly lost: 0 bytes in 0 blocks
==17717== still reachable: 10 bytes in 1 blocks
==17717== suppressed: 0 bytes in 0 blocks
==17717== Reachable blocks (those to which a pointer was found) are not shown.
==17717== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==17717==
==17717== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
==17717==
==17717== 1 errors in context 1 of 1:
==17717== Invalid read of size 1
==17717== at 0x4C31047: strcpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==17717== by 0x40119C: ??? (in /tmp/a.out)
==17717== by 0x4E5A82F: (below main) (libc-start.c:291)
==17717== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==17717==
==17717== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)
编辑 2:在 Docker 系统下测试在我的系统上编译的二进制文件后,问题似乎是相同的,导致认为问题出在二进制文件本身。使用 valgrind 可以很好地使用 Docker 系统的 GCC 进行编译。
编辑 3:刚刚编译了最新的 GCC 版本 (8.1.0) 并尝试用它编译程序:同样的问题。此外,您可能需要注意 valgrind 无法解析发生问题的函数,即使可执行文件没有 strip 化也是如此。
此外,在valgrind -v
命令中,我们在读取可执行文件的符号时,可以看到注释所有映射区域之外的ELF部分
。
我有点迷路了,它看起来既不是来自 GCC 也不是来自 Valgrind。也许是某种系统配置?
最佳答案
我使用 RedHat6 和 valgrind 3.9.0。我测试了以下编译器。对于所有编译器,我都使用了调试标志 -g
clang 4.0
==8862== Invalid read of size 1
==8862== at 0x4A09097: strcpy (in /opt/rh/devtoolset-2/root/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8862== by 0x400566: main (valg.c:10)
==8862== Address 0x0 is not stack'd, malloc'd or (recently) free'd
英特尔 icc 15.0.3
==8250== Invalid read of size 1
==8250== at 0x4A09097: strcpy (in /opt/rh/devtoolset-2/root/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8250== by 0x4005D2: main (valg.c:10)
==8250== Address 0x0 is not stack'd, malloc'd or (recently) free'd
海湾合作委员会 4.8.2
==8862== Invalid read of size 1
==8862== at 0x4A09097: strcpy (in /opt/rh/devtoolset-2/root/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8862== by 0x400566: main (valg.c:10)
==8862== Address 0x0 is not stack'd, malloc'd or (recently) free'd
它们都显示了正确的Invalid read of size 1
。执行程序时会抛出一个正确的 signal 11
。
这并不重要,如果您使用-v
或--leak-check=full
。
我知道这不是答案,但评论太长了。
关于c - Valgrind 看不到 -g 文件中的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50248365/
我想做的是让 JTextPane 在 JPanel 中占用尽可能多的空间。对于我使用的 UpdateInfoPanel: public class UpdateInfoPanel extends JP
我在 JPanel 中有一个 JTextArea,我想将其与 JScrollPane 一起使用。我正在使用 GridBagLayout。当我运行它时,框架似乎为 JScrollPane 腾出了空间,但
我想在 xcode 中实现以下功能。 我有一个 View Controller 。在这个 UIViewController 中,我有一个 UITabBar。它们下面是一个 UIView。将 UITab
有谁知道Firebird 2.5有没有类似于SQL中“STUFF”函数的功能? 我有一个包含父用户记录的表,另一个表包含与父相关的子用户记录。我希望能够提取用户拥有的“ROLES”的逗号分隔字符串,而
我想使用 JSON 作为 mirth channel 的输入和输出,例如详细信息保存在数据库中或创建 HL7 消息。 简而言之,输入为 JSON 解析它并输出为任何格式。 最佳答案 var objec
通常我会使用 R 并执行 merge.by,但这个文件似乎太大了,部门中的任何一台计算机都无法处理它! (任何从事遗传学工作的人的附加信息)本质上,插补似乎删除了 snp ID 的 rs 数字,我只剩
我有一个以前可能被问过的问题,但我很难找到正确的描述。我希望有人能帮助我。 在下面的代码中,我设置了varprice,我想添加javascript变量accu_id以通过rails在我的数据库中查找记
我有一个简单的 SVG 文件,在 Firefox 中可以正常查看 - 它的一些包装文本使用 foreignObject 包含一些 HTML - 文本包装在 div 中:
所以我正在为学校编写一个 Ruby 程序,如果某个值是 1 或 3,则将 bool 值更改为 true,如果是 0 或 2,则更改为 false。由于我有 Java 背景,所以我认为这段代码应该有效:
我做了什么: 我在这些账户之间创建了 VPC 对等连接 互联网网关也连接到每个 VPC 还配置了路由表(以允许来自双方的流量) 情况1: 当这两个 VPC 在同一个账户中时,我成功测试了从另一个 La
我有一个名为 contacts 的表: user_id contact_id 10294 10295 10294 10293 10293 10294 102
我正在使用 Magento 中的新模板。为避免重复代码,我想为每个产品预览使用相同的子模板。 特别是我做了这样一个展示: $products = Mage::getModel('catalog/pro
“for”是否总是检查协议(protocol)中定义的每个函数中第一个参数的类型? 编辑(改写): 当协议(protocol)方法只有一个参数时,根据该单个参数的类型(直接或任意)找到实现。当协议(p
我想从我的 PHP 代码中调用 JavaScript 函数。我通过使用以下方法实现了这一点: echo ' drawChart($id); '; 这工作正常,但我想从我的 PHP 代码中获取数据,我使
这个问题已经有答案了: Event binding on dynamically created elements? (23 个回答) 已关闭 5 年前。 我有一个动态表单,我想在其中附加一些其他 h
我正在尝试找到一种解决方案,以在 componentDidMount 中的映射项上使用 setState。 我正在使用 GraphQL连同 Gatsby返回许多 data 项目,但要求在特定的 pat
我在 ScrollView 中有一个 View 。只要用户按住该 View ,我想每 80 毫秒调用一次方法。这是我已经实现的: final Runnable vibrate = new Runnab
我用 jni 开发了一个 android 应用程序。我在 GetStringUTFChars 的 dvmDecodeIndirectRef 中得到了一个 dvmabort。我只中止了一次。 为什么会这
当我到达我的 Activity 时,我调用 FragmentPagerAdapter 来处理我的不同选项卡。在我的一个选项卡中,我想显示一个 RecyclerView,但他从未出现过,有了断点,我看到
当我按下 Activity 中的按钮时,会弹出一个 DialogFragment。在对话框 fragment 中,有一个看起来像普通 ListView 的 RecyclerView。 我想要的行为是当
我是一名优秀的程序员,十分优秀!