How to determine the cause for “BUS-Error”

雨燕双飞 提交于 2020-08-04 05:19:06

问题


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?


回答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.




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



来源:https://stackoverflow.com/questions/36970110/how-to-determine-the-cause-for-bus-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!