Domanda

Sto scrivendo una libreria di programmazione basata sull'evento per l'uso sul Beaglebone Black e hanno riscontrato uno strano errore.

Quando compilo lo stesso codice esatto con gli stessi identici flag che ricevo i seguenti errori sul processore basato sul braccio, ma non quando eseguo il codice compilato per il mio computer X86.

$ ./missionControl
pure virtual method called
pure virtual method called
pure virtual method called
terminate called recursively
terminate called recursively
Aborted
.

Quando compilo e corri sul mio laptop, il programma funziona correttamente .

Questo è il comando che sto usando per compilare (ISH, sto usando un Makefile, ma entrambi i metodi di compilazione mostrano precisamente lo stesso comportamento):

g++ -std=gnu++11 -pthread -O3 -D_GLIBCXX_USE_NANOSLEEP -o missionControl `find . -name *.cpp`
.

Non importa se ho compilato cross-compilare con il arm-linux-gnueabi-g++tagcode di Ubuntu o il g++ compatibile con braccioli sull'attuale beaglebone, ho ancora errori sul braccio.

La mia domanda è questa: cosa potrebbe causare questo errore, e cosa posso fare per cercare di trovare la fonte? Perché ciò accadesse su un'architettura del processore, ma non un'altra, per la stessa versione di G ++?

Grazie!

Ecco un backtrace dal GDB del processore del braccio:

#0  0xb6d4adf8 in raise () from /lib/libc.so.6
#1  0xb6d4e870 in abort () from /lib/libc.so.6
#2  0xb6f50ab4 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
#3  0xb6f4ea4c in ?? () from /usr/lib/libstdc++.so.6
#4  0xb6f4ea4c in ?? () from /usr/lib/libstdc++.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
.

È stato utile?

Soluzione

Il problema si è rivelato per essere dovuto a un bug nella versione del braccio di libstdc ++ che viene eseguito sulla Beaglebone.Un piccolo programma giocattolo che non ha funzioni virtuali fa in modo che lo stesso errore ("Funzione virtuale pura chiamata") quando viene creata la filettatura STD :: Thread.

Ho intenzione di provare a compilare una versione personalizzata di GCC / libstdc ++ 4.8 su Beaglebone stesso - anche se ci vuole molto tempo.

Altri suggerimenti

The pure virtual method called error occurs when you attempt to use dynamic dispatch to call a function that is pure virtual in a base before the derived type that implements it has been constructed or after it has already destructed.

The most common cause for this is if the base class attempts to call a virtual function that is pure at this level through the constructor or destructor. Other than that, as it has been pointed out in some comments, if you attempt to access a dead object, you might also run into this same issue.

Just attach a debugger to the program and see what virtual function is called and from where.

See: https://groups.google.com/forum/#!topic/automatak-dnp3/Jisp_zGhd5I

And: Why does this simple c++11 threading-example fail, when compiled with clang 3.2?

Now, I have no idea why this works, but it does for me at least. Add the following four preprocessor definitions to the compiler command line:

__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8

I haven't experimented to see if they are all required, or whether or not you can get away with only some. But this solved the problem for me. Thanks to those who wrote the above answers, and thanks to my colleague for out-googling me :)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top