arm7协程中opencv resize触发Bus error
Opened this issue · 13 comments
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <co/co.h>
#include <co/log.h>
DEC_bool(cout);
int main(int argc, char** argv)
{
co::init();
log::init();
FLG_cout = true;
co::WaitGroup wg;
auto mat = cv::imread("./bar.jpeg", cv::IMREAD_UNCHANGED);
cv::Mat tmp;
cv::resize(mat, tmp, cv::Size(100, 100));
LOG << "resize " << tmp.cols << " " << tmp.rows;
go([wg, mat]{
wg.add();
cv::Mat tmp;
cv::resize(mat, tmp, cv::Size(200, 200));
LOG << "resize2 " << tmp.cols << " " << tmp.rows;
wg.done();
});
wg.wait();
return 0;
}
堆栈
#0 cv::hal_baseline::v_int16x8::v_int16x8 (this=0x9fafd01c, v=...)
at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/_deps/opencv-src/modules/core/include/opencv2/core/hal/intrin_neon.hpp:206
#1 0xa4b53fd8 in cv::hal_baseline::v_load (ptr=0x9fb1e780)
at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/_deps/opencv-src/modules/core/include/opencv2/core/hal/intrin_neon.hpp:1277
#2 0xa4e1bcf0 in cv::HResizeLinearVecU8_X4::operator() (this=0x9fafd688, src=0x9fafd78c,
dst=0x9fafd74c, count=2, xofs=0x9fb1db00, alpha=0x9fb1e780, dmax=600, cn=3, xmax=600)
at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/_deps/opencv-src/modules/imgproc/src/resize.cpp:1744
#3 0xa4e4bd78 in cv::HResizeLinear<unsigned char, int, short, 2048, cv::HResizeLinearVecU8_X4>::operator() (this=0x9fafdbf8, src=0x9fafd78c, dst=0x9fafd74c, count=2, xofs=0x9fb1db00,
alpha=0x9fb1e780, swidth=3240, dwidth=600, cn=3, xmin=0, xmax=600)
at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/_deps/opencv-src/modules/imgproc/src/resize.cpp:1830
#4 0xa4e4357c in cv::resizeGeneric_Invoker<cv::HResizeLinear<unsigned char, int, short, 2048, cv::HResizeLinearVecU8_X4>, cv::VResizeLinear<unsigned char, int, short, cv::FixedPtCast<int, unsigned char, 22>, cv::VResizeLinearVec_32s8u> >::operator() (this=0x9fafdcfc, range=...)
at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/_deps/opencv-src/modules/imgproc/src/resize.cpp:2167
#5 0xa490fc04 in cv::parallel_for_impl (range=..., body=..., nstripes=0.6103515625)
at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/_deps/opencv-src/modules/core/src/parallel.cpp:540
#6 0xa490f9a8 in cv::parallel_for_ (range=..., body=..., nstripes=0.6103515625)
at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/_deps/opencv-src/modules/core/src/parallel.cpp:506
#7 0xa4e21438 in cv::resizeGeneric_<cv::HResizeLinear<unsigned char, int, short, 2048, cv::HResizeLinearVecU8_X4>, cv::VResizeLinear<unsigned char, int, short, cv::FixedPtCast<int, unsigned char, 22>, cv::VResizeLinearVec_32s8u> > (src=..., dst=..., xofs=0x9fb1db00, _alpha=0x9fb1e780,
yofs=0x9fb1e460, _beta=0x9fb1f0e0, xmin=0, xmax=600, ksize=2)
at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/_deps/opencv-src/modules/imgproc/src/resize.cpp:2204
#8 0xa4e20268 in cv::hal::resize (src_type=16,
--Type <RET> for more, q to quit, c to continue without paging--c
src_data=0x9ff25040 "4MQ-FJ)BF*CG0FK1GL3IN5KP6MO7OO2JJ1JF3NJ5QK5RI:VP9TQ0JJ7NP;RT0FK)?D.DJ2HN4GN5HO5HP2EM.AI.AI4GO9NV1HP+EL+CI.FL-EK)AG(@F,DJ.GK/HL/HL-FJ+DH+DH-FJ0IM/IO3MS5MS4LR6KS1FN0CK4GO0CK(;C/BI5HO,@E,@E2HM2IK3GH/DB,A"..., src_step=3240, src_width=1080, src_height=720, dst_data=0x9fb005c0 "", dst_step=600, dst_width=200, dst_height=200, inv_scale_x=0.18518518518518517, inv_scale_y=0.27777777777777779, interpolation=1) at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/_deps/opencv-src/modules/imgproc/src/resize.cpp:4036
#9 0xa4e209d8 in cv::resize (_src=..., _dst=..., dsize=..., inv_scale_x=0.18518518518518517, inv_scale_y=0.27777777777777779, interpolation=1) at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/_deps/opencv-src/modules/imgproc/src/resize.cpp:4089
#10 0x000126c0 in <lambda()>::operator()(void) const (__closure=0x340d4) at /Volumes/Docs/git/cppframe/frameworks/wuyi_core/main.cpp:26
#11 0x00014004 in co::xx::Function0<main(int, char**)::<lambda()> >::run(void) (this=0x340d0) at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/install/wuyi_util/include/co/closure.h:24
#12 0xa6477230 in co::SchedulerImpl::main_func (from=...) at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/_deps/libco-src/src/co/scheduler.cc:38
#13 0xa64b5b44 in tb_context_make () at /Volumes/Docs/git/cppframe/build-armeabihf-v7a-Debug/_deps/libco-src/src/co/context/context_arm.S:131
wg.add()
在 go 之前
wg.add();
go([wg, mat]{
cv::Mat tmp;
一样的错误,我猜想可能和arm7内存对齐问题有关,但是找不到解决方法
@aijle
看看你的问题,跟下面的是不是类似的?可能是 opencv 的一个 bug?
opencv/opencv#21047
应该不是,你看我的代码,cv::resize不在协程中是没问题的,而且错误是SIGBUS,一般都是内存对齐引起的。我现在用多线程处理cv::resize了。这里又有一个问题,一开始我用得std::async在协程里面处理,运行大约5300次后,程序就出现异常行为,但是也没有奔溃,直到我在外面创建一个线程处理,这才正常运行。有什么方法可以查看协程内存的情况,感觉是内存的问题。
用 coost 3.0
2升级3后,编译不了可能是什么原因
Undefined symbols for architecture x86_64:
"_FLG_max_log_file_size", referenced from
2升级3后,编译不了可能是什么原因 Undefined symbols for architecture x86_64: "_FLG_max_log_file_size"
如果用的是动态库,不要直接 DEC_xxx(max_log_file_size)
,v3.0 中没有导出这些符号
是的,我用nm查看了,3.0是没有。那怎么使用max_log_file_size
是的,我用nm查看了,3.0是没有。那怎么使用max_log_file_size
v3.0 中可以使用 flag::set_value()
接口。
确认下是否超默认的协程栈了,创建协程时候 调大点栈试试
确认下是否超默认的协程栈了,创建协程时候 调大点栈试试
@aijle 可以按 ruki 的建议试试,用 -co_stack_size 8m
将栈设成 8m 试试,默认只有 1m
感谢你们的提议,我前面设置了10m,尝试了升级到3,还是一样的问题。现在我用多线程解决这个问题,后面有时间再看。