I tried to use valgrind in order to debug some memory corruption, but when I run the program to debug using valgrind it ends reporting Illegal instruction.

So I tried with this very simple code :

#include <iostream>
int main()
    std::cout << "Hello" << std::endl;

And when valgrind a.out fails :

==2677== Memcheck, a memory error detector
==2677== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==2677== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==2677== Command: ./a.out
disInstr(arm): unhandled instruction: 0xF1010200
                 cond=15(0xF) 27:20=16(0x10) 4:4=0 3:0=0(0x0)
==2677== valgrind: Unrecognised instruction at address 0x4843588.
==2677==    at 0x4843588: ??? (in /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so)
==2677== Your program just tried to execute an instruction that Valgrind
==2677== did not recognise.  There are two possible reasons for this.
==2677== 1. Your program has a bug and erroneously jumped to a non-code
==2677==    location.  If you are running Memcheck and you just saw a
==2677==    warning about a bad jump, it's probably your program's fault.
==2677== 2. The instruction is legitimate but Valgrind doesn't handle it,
==2677==    i.e. it's Valgrind's fault.  If you think this is the case or
==2677==    you are not sure, please let us know and we'll try to fix it.
==2677== Either way, Valgrind will now raise a SIGILL signal which will
==2677== probably kill your program.
==2677== Process terminating with default action of signal 4 (SIGILL)
==2677==  Illegal opcode at address 0x4843588
==2677==    at 0x4843588: ??? (in /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so)
==2677== HEAP SUMMARY:
==2677==     in use at exit: 0 bytes in 0 blocks
==2677==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==2677== All heap blocks were freed -- no leaks are possible
==2677== For counts of detected and suppressed errors, rerun with: -v
==2677== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 19 from 6)
Illegal instruction

Is there a way to use valgrind on raspberry pi ?

2 Answers 2


There is a valgrind bug Bug 322935 - disInstr(arm): unhandled instruction: 0xF1010200, valgrind: Unrecognised instruction on Raspbian explains that std::cout << std::endl raise a SIGILL.

As the status is RESOLVED WONTFIX, I guess either I replace std::end with '\n' or I search an other way to debug.

  • I'm sure I've hit this before. Now here's an odd angle: On raspbian using \n instead works, on pidora (same valgrind version, "-3.7.0 and LibVEX"), I get the exact same error either way ("LibVEX called failure_exit()...report_and_quit (m_libcassert.c:235)") -- prefaced by "valgrind: the 'impossible' happened"...
    – goldilocks
    Commented Mar 29, 2015 at 9:57

I've been able to work around this problem by making sure the system can't find the particular library that contains the non-standard ARM instructions.

On Raspberry Pi 2:
sudo mv /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so_OLD

On Raspberry Pi 3:
sudo mv /usr/lib/arm-linux-gnueabihf/libarmmem.so /usr/lib/arm-linux-gnueabihf/libarmmem.so_OLD

This may produce some error messages regarding the missing libraries, but they do not seem to affect the proper functioning of Valgrind.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.