[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

Bus error

I checked the RAM with memtester, it seems to be okay.
How I can find the cause for the problems?

Enquirer: jeb


Solution #1:

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.

Respondent: Kamyar Souri

Solution #2:

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) )

Respondent: jeb

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.