linux - 使用 valgrind 时在 _dl_start 的堆栈指针下方写入无效
问题描述
我正在学习在嵌入式 ARM (rockchip rk3288) 平台上使用 valgrind:
valgrind /tmp/a.out
我不断收到这些错误:
==252== Memcheck, a memory error detector
==252== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==252== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info
==252== Command: /tmp/a.out
==252==
==252== Invalid write of size 4
==252== at 0x4001598: _dl_start (in /lib/ld-2.32.so)
==252== Address 0xbdbc6d3c is on thread 1's stack
==252== 36 bytes below stack pointer
==252==
==252== Invalid write of size 4
==252== at 0x4019174: _dl_sysdep_start (in /lib/ld-2.32.so)
==252== Address 0xbdbc6cf4 is on thread 1's stack
==252== 36 bytes below stack pointer
==252==
==252== Invalid write of size 4
==252== at 0x40184FC: __GI___tunables_init (in /lib/ld-2.32.so)
==252== Address 0xbdbc6c8c is on thread 1's stack
==252== 36 bytes below stack pointer
==252==
==252== Invalid write of size 4
==252== at 0x4002038: dl_main (in /lib/ld-2.32.so)
==252== Address 0xbdbc6c8c is on thread 1's stack
==252== 36 bytes below stack pointer
==252==
==252== Invalid write of size 4
==252== at 0x401D3AC: bcmp (in /lib/ld-2.32.so)
==252== Address 0xbdbc6a9c is on thread 1's stack
==252== 36 bytes below stack pointer
==252==
==252== Invalid write of size 4
==252== at 0x400278C: dl_main (in /lib/ld-2.32.so)
==252== Address 0xbdbc6a9c is on thread 1's stack
==252== 36 bytes below stack pointer
==252==
==252== Invalid write of size 4
==252== at 0x4019BEC: rtld_malloc (in /lib/ld-2.32.so)
==252== Address 0xbdbc6a84 is on thread 1's stack
==252== 12 bytes below stack pointer
==252==
==252== Conditional jump or move depends on uninitialised value(s)
==252== at 0x400C610: _dl_new_object (in /lib/ld-2.32.so)
==252==
==252== Invalid write of size 4
==252== at 0x40027B8: dl_main (in /lib/ld-2.32.so)
==252== Address 0xbdbc6aa0 is on thread 1's stack
==252== 32 bytes below stack pointer
==252==
==252== Use of uninitialised value of size 4
==252== at 0x400C258: _dl_add_to_namespace_list (in /lib/ld-2.32.so)
........
我正在使用内核 5.13.13 和 buildroot 2021.05.1(它构建了我的工具链,我也用它来编译我的内核)。
这是我的代码(t.cpp):
1 #include <cstdlib>
2 #include <iostream>
3
4 int main() {
5
6 std::cout << "allocating..." << std::endl;
7 void* p = malloc(1000);
8
9 std::cout << "freeing..." << std::endl;
10 free(p);
11 free(p);
12
13 return 0;
14 }
我正在使用这个 bash 脚本进行编译:
#!/bin/sh
export BUILDROOT_HOME=/home/user/buildroot
export SYSROOT=$BUILDROOT_HOME/output/staging
export PATH=$PATH:$BUILDROOT_HOME/output/host/usr/bin
arm-linux-g++ --sysroot=$SYSROOT t.cpp
我得到的错误似乎与我的代码无关。有什么想法可能是错的吗?
谢谢
解决方案
推荐阅读
- file - 使用 SSIS 导入 Fixedwidth 文件
- amazon-web-services - kops 'protectKernelDefaults' 标志和 'EventRateLimit' 准入插件不起作用
- asp.net-web-api - 尝试激活“AspNetCoreRateLimit.IpRateLimitMiddleware”时无法解析“AspNetCoreRateLimit.IProcessingStrategy”类型的服务
- sql - 如何从字符串 SQL 中提取数字
- acumatica - Acumatica:如何使用 REST API 覆盖销售订单中的 Bill-To Address 和 Ship-To Address
- javascript - 在反应css中使悬停弹出窗口不透明
- javascript - 如何处理“承诺{
}”在 JavaScript 中 - reactjs - React 中 PDF 的放大镜效果
- php - 在 ocmod opencart v2 中找不到错误代码
- php - 将 symfony 会话数据存储在两个不同的会话存储中