[Solved] How to determine the cause for “BUS-Error”
I’m working on a variscite board with a yocto distribution and python 2.7.3.
I get sometimes a Bus error message from the python interpreter.
My program runs normally at least some hours or days before the error ocours.
But when I get it once, I get it directly when I try to restart my program.
I have to reboot before the system works again.
My program uses only a serial port, a bit usb communication and some tcp sockets.
I can switch to another hardware and get the same problems.
I also used the python selftest with
python -c "from test import testall"
And I get errors for these two tests
test_getattr (test.test_builtin.BuiltinTest) … ERROR test_nameprep
(test.test_codecs.NameprepTest) … ERROR
And the selftest stops always at
test_callback_register_double (ctypes.test.test_callbacks.SampleCallbacksTestCase) … Segmentation
But when the systems runs some hours the selftests stops earlier at
I checked the RAM with memtester, it seems to be okay.
How I can find the cause for the problems?
Bus errors are generally caused by applications trying to access memory that hardware cannot physically address. In your case there is a segmentation fault which may cause dereferencing a bad pointer or something similar which leads to accessing a memory address which physically is not addressable. I’d start by root causing the segmentation fault first as the bus error is the secondary symptom.
A year later I found the indirect cause for the problems.
I wrote a crc16 module which used:
from ctypes import c_ushort ... value = c_ushort(crcValue >>8 ) ...
In case of a BUS-Error this was the problematic part.
I don’t assume that the c_ushort() function itself causes the problem, it’s only the function which shows that there is something broken.
The problem gone after upgrading the system to
Linux version 3.14.38-6QP+g8740b9f ([email protected]) (gcc version 4.9.2 (GCC) )