bus error opencv on jetson tk1


I’m getting a bus error when cvtColor runs, it appears to be cv::Mat &out that is causing it

void VisionPipeline::hslThreshold(cv::Mat &input, double hue], double sat], double lum], cv::Mat &out) {
	cv::cvtColor(input, out, cv::COLOR_BGR2HLS);
	cv::inRange(out, cv::Scalar(hue[0], lum[0], sat[0]), cv::Scalar(hue[1], lum[1], sat[1]), out);

it is being ran by:

	hslThreshold(hslThresholdInput, hslThresholdHue, hslThresholdSaturation, hslThresholdLuminance, this->hslThresholdOutput);

thanks for any help :slight_smile:


A bus error would typically occur if the buffer being written to is not correctly byte aligned.
The arm processor like intel doesn’t like it when a 2 or 4 byte entity is written to at an odd byte address.

If you are able to debug the issue with gdb, or the generated core file, you should be able to see the failing instruction. Dumping the target or source address from the register being used in the instruction will probably show an odd valued address.

If it’s the out buffer, I would look at how the buffer is being allocated and make sure it is correctly aligned for the data type.


here is what i get from gdb:

Program received signal SIGBUS, Bus error.
0x0000b5d2 in __gnu_cxx::__exchanged_and_add (__mem=0x2, __val=-1)
at /usr/include/c++/4.8/ext/atomicity.h:49
49     { return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }


0x0000b5d2 appears not to be byte aligned, how would i align it?


Ok we fixed it by eliminating some pointers


__mem does not look valid (2). It appears to be an invalid pointer.