Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 fault

But when the systems runs some hours the selftests stops earlier at

ctypes.macholib.dyld Bus error

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

like image 366
jeb Avatar asked May 01 '16 18:05

jeb


2 Answers

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.

like image 74
Kamyar Souri Avatar answered Sep 23 '22 08:09

Kamyar Souri


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 (test@Yocto) (gcc version 4.9.2 (GCC) )

like image 28
jeb Avatar answered Sep 21 '22 08:09

jeb