#linux #arm #g #valgrind #buildroot
Вопрос:
Я учусь использовать valgrind на встроенной платформе ARM (rockchip rk3288) :
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
The errors I’m getting seem to be unrelated to my code. Any ideas what could be wrong?
Thanks