Linux program cashed with message PC in COEF()
any body who knows what happened to my program,i have enabled two signals,sigalarm & sigio,what is the meaning of COEF(), i googled it, little information about it. when my program crashed accidentally, segmentation fault showed in the shell command line
warning: core file may not match specified executable file.
[New LWP 162]
[New LWP 159]
Core was generated by `./main'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00029a4c in COEF ()
[Current thread is 1 (LWP 162)]
(gdb) bt
#0 0x00029a4c in COEF ()
#1 <signal handler called>
#2 __libc_do_syscall () at ../ports/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:43
#3 0xb6f036e6 in do_futex_wait (isem=isem@entry=0xf67a8 <global_setting+24>)
at ../nptl/sysdeps/unix/sysv/linux/sem_wait.c:48
#4 0xb6f03752 in __new_sem_wait (sem=0xf67a8 <global_setting+24>) at ../nptl/sysdeps/unix/sysv/linux/sem_wait.c:69
#5 0x00012286 in identify_task () at ./src/main.cpp:16
#6 0x000138ac in std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (this=0xbed2e8)
at d:program files (x86)gcc-linaro-4.9.4-2017.01-i686-mingw32_arm-linux-gnueabihfarm-linux-gnueabihfincludec++4.9.4/functional:1700
#7 0x00013804 in std::_Bind_simple<void (*())()>::operator()() (this=0xbed2e8)
at d:program files (x86)gcc-linaro-4.9.4-2017.01-i686-mingw32_arm-linux-gnueabihfarm-linux-gnueabihfincludec++4.9.4/functional:1688
#8 0x000137a6 in std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (this=0xbed2dc)
at d:program files (x86)gcc-linaro-4.9.4-2017.01-i686-mingw32_arm-linux-gnueabihfarm-linux-gnueabihfincludec++4.9.4/thread:115
#9 0xb6ec737c in std::execute_native_thread_routine (__p=<optimized out>)
at /home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/snapshots/gcc-linaro-4.9-2017.01/libstdc++-v3/src/c++11/thread.cc:84
#10 0xb6ef8e72 in (anonymous namespace)::get_safe_base_mutex(void*)::safe_base_mutex ()
from C:msys64homezhangivanreleaseliblibstdc++.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) info symbol COEF
COEF in section .rodata of C:msys64homezhangivanreleasemain
(gdb)
i created a thread for processing data sent from signal handler timer_isr(int),below is the task i created
#define PATH_LEN 100
char pathstr[PATH_LEN] = {0};
void identify_task()
{
int label = 0;
uint8_t(*pic)[PIC_WIDTH] = NULL;
int pic_height = 0;
rs3_t rs3;
for (;;)
{
sem_wait(&global_setting.identify_semaphore);
pic_height = global_setting.pic_height;
if (pic_height > MAX_HEIGHT || pic_height == 0)
{
continue;
}
/* get a pic buffer from pic queue */
if (dequeue(global_setting.pic_queue, reinterpret_cast<uint32_t *>(&pic)) == 0)
{
continue;
}
if (pic == NULL)
{
continue;
}
#if DEBUG || MEASURE_TIME
int begin = clock();
#endif
if (1 == global_setting.is_predict)
{ /*do process predicting*/
label = predict(pic, pic_height);
}
else
{ /* not do & assign a constant 10 */
label = 10;
}
#if DEBUG || MEASURE_TIME
int end = clock();
printf("cash label:%3d,predict time elapsed:%dn", label, end - begin);
#endif
/* response a cash denomination value to control board */
rs3.data[0] = 0;
rs3.data[1] = label;
rs3.chk = instruction_check<rs3_t>(&rs3);
write(global_setting.uart_fd, &rs3, sizeof(rs3_t));
#if DEBUG || SAVE_PIC
/* storage this picture and name each file with different suffix */
static uint32_t picno = 0;
memset(pathstr, 0, PATH_LEN);
sprintf(pathstr, "./pics/128*%d_%d.bmp", pic_height, picno++);
save_pic(pic, pic_height, pathstr);
#endif
/* this pic buffer is used, so enqueue it into empty buffer */
enqueue(global_setting.empty_queue, reinterpret_cast<uint32_t>(pic));
}
}
here is my sigalarm handler,i noticed it crashed in it. this handler first sample some data using SPI, than post a semaphore
void timer_isr(int signo)
{
static int height = 0, lastheight = -1, start = 0;
uint32_t sum = 0;
if (spi_get_data(global_setting.spi_fd, spi_buf, PIC_WIDTH + 1) == 0)
{
return;
}
else
{
global_setting.system_status = RS1_NORMAL;
}
/* crc check */
if (spi_buf[PIC_WIDTH] != crc_check(spi_buf, PIC_WIDTH))
{
return;
}
#if PIC_TEST
static int pic_test_i = 0;
if (pic_test_i >= MAX_HEIGHT)
{
pic_test_i = 0;
}
memcpy(spi_buf, reinterpret_cast<uint8_t(*)[PIC_WIDTH]>(global_setting.test_pic)[pic_test_i], PIC_WIDTH);
pic_test_i++;
#endif
sum = get_sum<uint8_t>(spi_buf, PIC_WIDTH);
/* scan for 5000 times & get smallest boundary value */
if (boundary_cnter < 5000)
{
if (global_setting.boundary > sum)
{
global_setting.boundary = sum;
}
boundary_cnter++;
return;
}
else if (boundary_cnter == 5000)
{
global_setting.boundary -= 700;
boundary_cnter++;
}
/* here we compare sum with initial asured boundary
if sum is smaller than boundary, then store this
pixel data
*/
#if PIC_TEST
if (sum < 4000)
#else
if (sum < global_setting.boundary)
#endif
{
/* pic started */
start = 1;
/* if pic buffer is null, so pick one pic buffer from empty queue */
if (pic == NULL)
{
if (dequeue(global_setting.empty_queue, reinterpret_cast<uint32_t *>(&pic)) == 0)
{
return;
}
if (pic == NULL)
{
return;
}
}
memcpy(pic[height], spi_buf, PIC_WIDTH);
if (height < (MAX_HEIGHT - 1))
{
height++;
}
}
/* here if all these condictions are met, well, full cash picture is sampled */
if (start == 1 && height - lastheight == 0 && height > 0)
{
/* enqueue this pic buffer into on using queue */
if (enqueue(global_setting.pic_queue, reinterpret_cast<uint32_t>(pic)) == 1)
{
global_setting.pic_height = height;
/* notify identify_task */
sem_post(&global_setting.identify_semaphore);
/* now this pic buffer is used,so reset pic pointer */
pic = NULL;
height = 0;
start = 0;
}
}
lastheight = height;
}
and below is my timer_isr(int) regester function
int timer_init(void fun(int),int us)
{
int res = 0;
struct itimerval tick;
signal(SIGALRM, fun);
memset(&tick, 0, sizeof(tick));
//Timeout to run first time
tick.it_value.tv_sec = 0;
tick.it_value.tv_usec = 200;
//After first, the Interval time for clock
tick.it_interval.tv_sec = 0;
tick.it_interval.tv_usec = us;
if(setitimer(ITIMER_REAL, &tick, NULL) < 0)
{
printf("Set timer failed!n");
return -1;
}
return 0;
}
i checked my process stack is 8192KB, it could not be caused by stack overflow
c++ linux
|
show 6 more comments
any body who knows what happened to my program,i have enabled two signals,sigalarm & sigio,what is the meaning of COEF(), i googled it, little information about it. when my program crashed accidentally, segmentation fault showed in the shell command line
warning: core file may not match specified executable file.
[New LWP 162]
[New LWP 159]
Core was generated by `./main'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00029a4c in COEF ()
[Current thread is 1 (LWP 162)]
(gdb) bt
#0 0x00029a4c in COEF ()
#1 <signal handler called>
#2 __libc_do_syscall () at ../ports/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:43
#3 0xb6f036e6 in do_futex_wait (isem=isem@entry=0xf67a8 <global_setting+24>)
at ../nptl/sysdeps/unix/sysv/linux/sem_wait.c:48
#4 0xb6f03752 in __new_sem_wait (sem=0xf67a8 <global_setting+24>) at ../nptl/sysdeps/unix/sysv/linux/sem_wait.c:69
#5 0x00012286 in identify_task () at ./src/main.cpp:16
#6 0x000138ac in std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (this=0xbed2e8)
at d:program files (x86)gcc-linaro-4.9.4-2017.01-i686-mingw32_arm-linux-gnueabihfarm-linux-gnueabihfincludec++4.9.4/functional:1700
#7 0x00013804 in std::_Bind_simple<void (*())()>::operator()() (this=0xbed2e8)
at d:program files (x86)gcc-linaro-4.9.4-2017.01-i686-mingw32_arm-linux-gnueabihfarm-linux-gnueabihfincludec++4.9.4/functional:1688
#8 0x000137a6 in std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (this=0xbed2dc)
at d:program files (x86)gcc-linaro-4.9.4-2017.01-i686-mingw32_arm-linux-gnueabihfarm-linux-gnueabihfincludec++4.9.4/thread:115
#9 0xb6ec737c in std::execute_native_thread_routine (__p=<optimized out>)
at /home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/snapshots/gcc-linaro-4.9-2017.01/libstdc++-v3/src/c++11/thread.cc:84
#10 0xb6ef8e72 in (anonymous namespace)::get_safe_base_mutex(void*)::safe_base_mutex ()
from C:msys64homezhangivanreleaseliblibstdc++.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) info symbol COEF
COEF in section .rodata of C:msys64homezhangivanreleasemain
(gdb)
i created a thread for processing data sent from signal handler timer_isr(int),below is the task i created
#define PATH_LEN 100
char pathstr[PATH_LEN] = {0};
void identify_task()
{
int label = 0;
uint8_t(*pic)[PIC_WIDTH] = NULL;
int pic_height = 0;
rs3_t rs3;
for (;;)
{
sem_wait(&global_setting.identify_semaphore);
pic_height = global_setting.pic_height;
if (pic_height > MAX_HEIGHT || pic_height == 0)
{
continue;
}
/* get a pic buffer from pic queue */
if (dequeue(global_setting.pic_queue, reinterpret_cast<uint32_t *>(&pic)) == 0)
{
continue;
}
if (pic == NULL)
{
continue;
}
#if DEBUG || MEASURE_TIME
int begin = clock();
#endif
if (1 == global_setting.is_predict)
{ /*do process predicting*/
label = predict(pic, pic_height);
}
else
{ /* not do & assign a constant 10 */
label = 10;
}
#if DEBUG || MEASURE_TIME
int end = clock();
printf("cash label:%3d,predict time elapsed:%dn", label, end - begin);
#endif
/* response a cash denomination value to control board */
rs3.data[0] = 0;
rs3.data[1] = label;
rs3.chk = instruction_check<rs3_t>(&rs3);
write(global_setting.uart_fd, &rs3, sizeof(rs3_t));
#if DEBUG || SAVE_PIC
/* storage this picture and name each file with different suffix */
static uint32_t picno = 0;
memset(pathstr, 0, PATH_LEN);
sprintf(pathstr, "./pics/128*%d_%d.bmp", pic_height, picno++);
save_pic(pic, pic_height, pathstr);
#endif
/* this pic buffer is used, so enqueue it into empty buffer */
enqueue(global_setting.empty_queue, reinterpret_cast<uint32_t>(pic));
}
}
here is my sigalarm handler,i noticed it crashed in it. this handler first sample some data using SPI, than post a semaphore
void timer_isr(int signo)
{
static int height = 0, lastheight = -1, start = 0;
uint32_t sum = 0;
if (spi_get_data(global_setting.spi_fd, spi_buf, PIC_WIDTH + 1) == 0)
{
return;
}
else
{
global_setting.system_status = RS1_NORMAL;
}
/* crc check */
if (spi_buf[PIC_WIDTH] != crc_check(spi_buf, PIC_WIDTH))
{
return;
}
#if PIC_TEST
static int pic_test_i = 0;
if (pic_test_i >= MAX_HEIGHT)
{
pic_test_i = 0;
}
memcpy(spi_buf, reinterpret_cast<uint8_t(*)[PIC_WIDTH]>(global_setting.test_pic)[pic_test_i], PIC_WIDTH);
pic_test_i++;
#endif
sum = get_sum<uint8_t>(spi_buf, PIC_WIDTH);
/* scan for 5000 times & get smallest boundary value */
if (boundary_cnter < 5000)
{
if (global_setting.boundary > sum)
{
global_setting.boundary = sum;
}
boundary_cnter++;
return;
}
else if (boundary_cnter == 5000)
{
global_setting.boundary -= 700;
boundary_cnter++;
}
/* here we compare sum with initial asured boundary
if sum is smaller than boundary, then store this
pixel data
*/
#if PIC_TEST
if (sum < 4000)
#else
if (sum < global_setting.boundary)
#endif
{
/* pic started */
start = 1;
/* if pic buffer is null, so pick one pic buffer from empty queue */
if (pic == NULL)
{
if (dequeue(global_setting.empty_queue, reinterpret_cast<uint32_t *>(&pic)) == 0)
{
return;
}
if (pic == NULL)
{
return;
}
}
memcpy(pic[height], spi_buf, PIC_WIDTH);
if (height < (MAX_HEIGHT - 1))
{
height++;
}
}
/* here if all these condictions are met, well, full cash picture is sampled */
if (start == 1 && height - lastheight == 0 && height > 0)
{
/* enqueue this pic buffer into on using queue */
if (enqueue(global_setting.pic_queue, reinterpret_cast<uint32_t>(pic)) == 1)
{
global_setting.pic_height = height;
/* notify identify_task */
sem_post(&global_setting.identify_semaphore);
/* now this pic buffer is used,so reset pic pointer */
pic = NULL;
height = 0;
start = 0;
}
}
lastheight = height;
}
and below is my timer_isr(int) regester function
int timer_init(void fun(int),int us)
{
int res = 0;
struct itimerval tick;
signal(SIGALRM, fun);
memset(&tick, 0, sizeof(tick));
//Timeout to run first time
tick.it_value.tv_sec = 0;
tick.it_value.tv_usec = 200;
//After first, the Interval time for clock
tick.it_interval.tv_sec = 0;
tick.it_interval.tv_usec = us;
if(setitimer(ITIMER_REAL, &tick, NULL) < 0)
{
printf("Set timer failed!n");
return -1;
}
return 0;
}
i checked my process stack is 8192KB, it could not be caused by stack overflow
c++ linux
1
Did you forget to post the code?
– 4386427
Dec 28 '18 at 8:03
Please paste error messages as plain text into your question. Going by the backtrace, you are using C++std::thread
. Please give a Minimal, Complete, and Verifiable example of your code reproducing the error and retag your question to C++ if you are writing in C++. Also: What is the original error? I only see a backtrace.
– user10605163
Dec 28 '18 at 8:05
i debug my program with core dump file, all i can see is PC goes into COEF(), i dont know what is COEF(), is it a default signal handler
– blithe
Dec 28 '18 at 8:34
i have checked my code, every thing is ok , i just wonder what is COEF()
– blithe
Dec 28 '18 at 8:47
gdb
is reporting your stack may be corrupt, so I am not sure you can actually trust the backtrace. It is also possible your program crashed twice, so you are looking at your signal handler crashing. There is not enough information to diagnose the issue, because you have not presented enough information to deduce how to reproduce the problem.
– jxh
Dec 28 '18 at 9:46
|
show 6 more comments
any body who knows what happened to my program,i have enabled two signals,sigalarm & sigio,what is the meaning of COEF(), i googled it, little information about it. when my program crashed accidentally, segmentation fault showed in the shell command line
warning: core file may not match specified executable file.
[New LWP 162]
[New LWP 159]
Core was generated by `./main'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00029a4c in COEF ()
[Current thread is 1 (LWP 162)]
(gdb) bt
#0 0x00029a4c in COEF ()
#1 <signal handler called>
#2 __libc_do_syscall () at ../ports/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:43
#3 0xb6f036e6 in do_futex_wait (isem=isem@entry=0xf67a8 <global_setting+24>)
at ../nptl/sysdeps/unix/sysv/linux/sem_wait.c:48
#4 0xb6f03752 in __new_sem_wait (sem=0xf67a8 <global_setting+24>) at ../nptl/sysdeps/unix/sysv/linux/sem_wait.c:69
#5 0x00012286 in identify_task () at ./src/main.cpp:16
#6 0x000138ac in std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (this=0xbed2e8)
at d:program files (x86)gcc-linaro-4.9.4-2017.01-i686-mingw32_arm-linux-gnueabihfarm-linux-gnueabihfincludec++4.9.4/functional:1700
#7 0x00013804 in std::_Bind_simple<void (*())()>::operator()() (this=0xbed2e8)
at d:program files (x86)gcc-linaro-4.9.4-2017.01-i686-mingw32_arm-linux-gnueabihfarm-linux-gnueabihfincludec++4.9.4/functional:1688
#8 0x000137a6 in std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (this=0xbed2dc)
at d:program files (x86)gcc-linaro-4.9.4-2017.01-i686-mingw32_arm-linux-gnueabihfarm-linux-gnueabihfincludec++4.9.4/thread:115
#9 0xb6ec737c in std::execute_native_thread_routine (__p=<optimized out>)
at /home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/snapshots/gcc-linaro-4.9-2017.01/libstdc++-v3/src/c++11/thread.cc:84
#10 0xb6ef8e72 in (anonymous namespace)::get_safe_base_mutex(void*)::safe_base_mutex ()
from C:msys64homezhangivanreleaseliblibstdc++.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) info symbol COEF
COEF in section .rodata of C:msys64homezhangivanreleasemain
(gdb)
i created a thread for processing data sent from signal handler timer_isr(int),below is the task i created
#define PATH_LEN 100
char pathstr[PATH_LEN] = {0};
void identify_task()
{
int label = 0;
uint8_t(*pic)[PIC_WIDTH] = NULL;
int pic_height = 0;
rs3_t rs3;
for (;;)
{
sem_wait(&global_setting.identify_semaphore);
pic_height = global_setting.pic_height;
if (pic_height > MAX_HEIGHT || pic_height == 0)
{
continue;
}
/* get a pic buffer from pic queue */
if (dequeue(global_setting.pic_queue, reinterpret_cast<uint32_t *>(&pic)) == 0)
{
continue;
}
if (pic == NULL)
{
continue;
}
#if DEBUG || MEASURE_TIME
int begin = clock();
#endif
if (1 == global_setting.is_predict)
{ /*do process predicting*/
label = predict(pic, pic_height);
}
else
{ /* not do & assign a constant 10 */
label = 10;
}
#if DEBUG || MEASURE_TIME
int end = clock();
printf("cash label:%3d,predict time elapsed:%dn", label, end - begin);
#endif
/* response a cash denomination value to control board */
rs3.data[0] = 0;
rs3.data[1] = label;
rs3.chk = instruction_check<rs3_t>(&rs3);
write(global_setting.uart_fd, &rs3, sizeof(rs3_t));
#if DEBUG || SAVE_PIC
/* storage this picture and name each file with different suffix */
static uint32_t picno = 0;
memset(pathstr, 0, PATH_LEN);
sprintf(pathstr, "./pics/128*%d_%d.bmp", pic_height, picno++);
save_pic(pic, pic_height, pathstr);
#endif
/* this pic buffer is used, so enqueue it into empty buffer */
enqueue(global_setting.empty_queue, reinterpret_cast<uint32_t>(pic));
}
}
here is my sigalarm handler,i noticed it crashed in it. this handler first sample some data using SPI, than post a semaphore
void timer_isr(int signo)
{
static int height = 0, lastheight = -1, start = 0;
uint32_t sum = 0;
if (spi_get_data(global_setting.spi_fd, spi_buf, PIC_WIDTH + 1) == 0)
{
return;
}
else
{
global_setting.system_status = RS1_NORMAL;
}
/* crc check */
if (spi_buf[PIC_WIDTH] != crc_check(spi_buf, PIC_WIDTH))
{
return;
}
#if PIC_TEST
static int pic_test_i = 0;
if (pic_test_i >= MAX_HEIGHT)
{
pic_test_i = 0;
}
memcpy(spi_buf, reinterpret_cast<uint8_t(*)[PIC_WIDTH]>(global_setting.test_pic)[pic_test_i], PIC_WIDTH);
pic_test_i++;
#endif
sum = get_sum<uint8_t>(spi_buf, PIC_WIDTH);
/* scan for 5000 times & get smallest boundary value */
if (boundary_cnter < 5000)
{
if (global_setting.boundary > sum)
{
global_setting.boundary = sum;
}
boundary_cnter++;
return;
}
else if (boundary_cnter == 5000)
{
global_setting.boundary -= 700;
boundary_cnter++;
}
/* here we compare sum with initial asured boundary
if sum is smaller than boundary, then store this
pixel data
*/
#if PIC_TEST
if (sum < 4000)
#else
if (sum < global_setting.boundary)
#endif
{
/* pic started */
start = 1;
/* if pic buffer is null, so pick one pic buffer from empty queue */
if (pic == NULL)
{
if (dequeue(global_setting.empty_queue, reinterpret_cast<uint32_t *>(&pic)) == 0)
{
return;
}
if (pic == NULL)
{
return;
}
}
memcpy(pic[height], spi_buf, PIC_WIDTH);
if (height < (MAX_HEIGHT - 1))
{
height++;
}
}
/* here if all these condictions are met, well, full cash picture is sampled */
if (start == 1 && height - lastheight == 0 && height > 0)
{
/* enqueue this pic buffer into on using queue */
if (enqueue(global_setting.pic_queue, reinterpret_cast<uint32_t>(pic)) == 1)
{
global_setting.pic_height = height;
/* notify identify_task */
sem_post(&global_setting.identify_semaphore);
/* now this pic buffer is used,so reset pic pointer */
pic = NULL;
height = 0;
start = 0;
}
}
lastheight = height;
}
and below is my timer_isr(int) regester function
int timer_init(void fun(int),int us)
{
int res = 0;
struct itimerval tick;
signal(SIGALRM, fun);
memset(&tick, 0, sizeof(tick));
//Timeout to run first time
tick.it_value.tv_sec = 0;
tick.it_value.tv_usec = 200;
//After first, the Interval time for clock
tick.it_interval.tv_sec = 0;
tick.it_interval.tv_usec = us;
if(setitimer(ITIMER_REAL, &tick, NULL) < 0)
{
printf("Set timer failed!n");
return -1;
}
return 0;
}
i checked my process stack is 8192KB, it could not be caused by stack overflow
c++ linux
any body who knows what happened to my program,i have enabled two signals,sigalarm & sigio,what is the meaning of COEF(), i googled it, little information about it. when my program crashed accidentally, segmentation fault showed in the shell command line
warning: core file may not match specified executable file.
[New LWP 162]
[New LWP 159]
Core was generated by `./main'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00029a4c in COEF ()
[Current thread is 1 (LWP 162)]
(gdb) bt
#0 0x00029a4c in COEF ()
#1 <signal handler called>
#2 __libc_do_syscall () at ../ports/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:43
#3 0xb6f036e6 in do_futex_wait (isem=isem@entry=0xf67a8 <global_setting+24>)
at ../nptl/sysdeps/unix/sysv/linux/sem_wait.c:48
#4 0xb6f03752 in __new_sem_wait (sem=0xf67a8 <global_setting+24>) at ../nptl/sysdeps/unix/sysv/linux/sem_wait.c:69
#5 0x00012286 in identify_task () at ./src/main.cpp:16
#6 0x000138ac in std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>) (this=0xbed2e8)
at d:program files (x86)gcc-linaro-4.9.4-2017.01-i686-mingw32_arm-linux-gnueabihfarm-linux-gnueabihfincludec++4.9.4/functional:1700
#7 0x00013804 in std::_Bind_simple<void (*())()>::operator()() (this=0xbed2e8)
at d:program files (x86)gcc-linaro-4.9.4-2017.01-i686-mingw32_arm-linux-gnueabihfarm-linux-gnueabihfincludec++4.9.4/functional:1688
#8 0x000137a6 in std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run() (this=0xbed2dc)
at d:program files (x86)gcc-linaro-4.9.4-2017.01-i686-mingw32_arm-linux-gnueabihfarm-linux-gnueabihfincludec++4.9.4/thread:115
#9 0xb6ec737c in std::execute_native_thread_routine (__p=<optimized out>)
at /home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/snapshots/gcc-linaro-4.9-2017.01/libstdc++-v3/src/c++11/thread.cc:84
#10 0xb6ef8e72 in (anonymous namespace)::get_safe_base_mutex(void*)::safe_base_mutex ()
from C:msys64homezhangivanreleaseliblibstdc++.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) info symbol COEF
COEF in section .rodata of C:msys64homezhangivanreleasemain
(gdb)
i created a thread for processing data sent from signal handler timer_isr(int),below is the task i created
#define PATH_LEN 100
char pathstr[PATH_LEN] = {0};
void identify_task()
{
int label = 0;
uint8_t(*pic)[PIC_WIDTH] = NULL;
int pic_height = 0;
rs3_t rs3;
for (;;)
{
sem_wait(&global_setting.identify_semaphore);
pic_height = global_setting.pic_height;
if (pic_height > MAX_HEIGHT || pic_height == 0)
{
continue;
}
/* get a pic buffer from pic queue */
if (dequeue(global_setting.pic_queue, reinterpret_cast<uint32_t *>(&pic)) == 0)
{
continue;
}
if (pic == NULL)
{
continue;
}
#if DEBUG || MEASURE_TIME
int begin = clock();
#endif
if (1 == global_setting.is_predict)
{ /*do process predicting*/
label = predict(pic, pic_height);
}
else
{ /* not do & assign a constant 10 */
label = 10;
}
#if DEBUG || MEASURE_TIME
int end = clock();
printf("cash label:%3d,predict time elapsed:%dn", label, end - begin);
#endif
/* response a cash denomination value to control board */
rs3.data[0] = 0;
rs3.data[1] = label;
rs3.chk = instruction_check<rs3_t>(&rs3);
write(global_setting.uart_fd, &rs3, sizeof(rs3_t));
#if DEBUG || SAVE_PIC
/* storage this picture and name each file with different suffix */
static uint32_t picno = 0;
memset(pathstr, 0, PATH_LEN);
sprintf(pathstr, "./pics/128*%d_%d.bmp", pic_height, picno++);
save_pic(pic, pic_height, pathstr);
#endif
/* this pic buffer is used, so enqueue it into empty buffer */
enqueue(global_setting.empty_queue, reinterpret_cast<uint32_t>(pic));
}
}
here is my sigalarm handler,i noticed it crashed in it. this handler first sample some data using SPI, than post a semaphore
void timer_isr(int signo)
{
static int height = 0, lastheight = -1, start = 0;
uint32_t sum = 0;
if (spi_get_data(global_setting.spi_fd, spi_buf, PIC_WIDTH + 1) == 0)
{
return;
}
else
{
global_setting.system_status = RS1_NORMAL;
}
/* crc check */
if (spi_buf[PIC_WIDTH] != crc_check(spi_buf, PIC_WIDTH))
{
return;
}
#if PIC_TEST
static int pic_test_i = 0;
if (pic_test_i >= MAX_HEIGHT)
{
pic_test_i = 0;
}
memcpy(spi_buf, reinterpret_cast<uint8_t(*)[PIC_WIDTH]>(global_setting.test_pic)[pic_test_i], PIC_WIDTH);
pic_test_i++;
#endif
sum = get_sum<uint8_t>(spi_buf, PIC_WIDTH);
/* scan for 5000 times & get smallest boundary value */
if (boundary_cnter < 5000)
{
if (global_setting.boundary > sum)
{
global_setting.boundary = sum;
}
boundary_cnter++;
return;
}
else if (boundary_cnter == 5000)
{
global_setting.boundary -= 700;
boundary_cnter++;
}
/* here we compare sum with initial asured boundary
if sum is smaller than boundary, then store this
pixel data
*/
#if PIC_TEST
if (sum < 4000)
#else
if (sum < global_setting.boundary)
#endif
{
/* pic started */
start = 1;
/* if pic buffer is null, so pick one pic buffer from empty queue */
if (pic == NULL)
{
if (dequeue(global_setting.empty_queue, reinterpret_cast<uint32_t *>(&pic)) == 0)
{
return;
}
if (pic == NULL)
{
return;
}
}
memcpy(pic[height], spi_buf, PIC_WIDTH);
if (height < (MAX_HEIGHT - 1))
{
height++;
}
}
/* here if all these condictions are met, well, full cash picture is sampled */
if (start == 1 && height - lastheight == 0 && height > 0)
{
/* enqueue this pic buffer into on using queue */
if (enqueue(global_setting.pic_queue, reinterpret_cast<uint32_t>(pic)) == 1)
{
global_setting.pic_height = height;
/* notify identify_task */
sem_post(&global_setting.identify_semaphore);
/* now this pic buffer is used,so reset pic pointer */
pic = NULL;
height = 0;
start = 0;
}
}
lastheight = height;
}
and below is my timer_isr(int) regester function
int timer_init(void fun(int),int us)
{
int res = 0;
struct itimerval tick;
signal(SIGALRM, fun);
memset(&tick, 0, sizeof(tick));
//Timeout to run first time
tick.it_value.tv_sec = 0;
tick.it_value.tv_usec = 200;
//After first, the Interval time for clock
tick.it_interval.tv_sec = 0;
tick.it_interval.tv_usec = us;
if(setitimer(ITIMER_REAL, &tick, NULL) < 0)
{
printf("Set timer failed!n");
return -1;
}
return 0;
}
i checked my process stack is 8192KB, it could not be caused by stack overflow
c++ linux
c++ linux
edited Dec 28 '18 at 12:44
blithe
asked Dec 28 '18 at 7:45
blitheblithe
11
11
1
Did you forget to post the code?
– 4386427
Dec 28 '18 at 8:03
Please paste error messages as plain text into your question. Going by the backtrace, you are using C++std::thread
. Please give a Minimal, Complete, and Verifiable example of your code reproducing the error and retag your question to C++ if you are writing in C++. Also: What is the original error? I only see a backtrace.
– user10605163
Dec 28 '18 at 8:05
i debug my program with core dump file, all i can see is PC goes into COEF(), i dont know what is COEF(), is it a default signal handler
– blithe
Dec 28 '18 at 8:34
i have checked my code, every thing is ok , i just wonder what is COEF()
– blithe
Dec 28 '18 at 8:47
gdb
is reporting your stack may be corrupt, so I am not sure you can actually trust the backtrace. It is also possible your program crashed twice, so you are looking at your signal handler crashing. There is not enough information to diagnose the issue, because you have not presented enough information to deduce how to reproduce the problem.
– jxh
Dec 28 '18 at 9:46
|
show 6 more comments
1
Did you forget to post the code?
– 4386427
Dec 28 '18 at 8:03
Please paste error messages as plain text into your question. Going by the backtrace, you are using C++std::thread
. Please give a Minimal, Complete, and Verifiable example of your code reproducing the error and retag your question to C++ if you are writing in C++. Also: What is the original error? I only see a backtrace.
– user10605163
Dec 28 '18 at 8:05
i debug my program with core dump file, all i can see is PC goes into COEF(), i dont know what is COEF(), is it a default signal handler
– blithe
Dec 28 '18 at 8:34
i have checked my code, every thing is ok , i just wonder what is COEF()
– blithe
Dec 28 '18 at 8:47
gdb
is reporting your stack may be corrupt, so I am not sure you can actually trust the backtrace. It is also possible your program crashed twice, so you are looking at your signal handler crashing. There is not enough information to diagnose the issue, because you have not presented enough information to deduce how to reproduce the problem.
– jxh
Dec 28 '18 at 9:46
1
1
Did you forget to post the code?
– 4386427
Dec 28 '18 at 8:03
Did you forget to post the code?
– 4386427
Dec 28 '18 at 8:03
Please paste error messages as plain text into your question. Going by the backtrace, you are using C++
std::thread
. Please give a Minimal, Complete, and Verifiable example of your code reproducing the error and retag your question to C++ if you are writing in C++. Also: What is the original error? I only see a backtrace.– user10605163
Dec 28 '18 at 8:05
Please paste error messages as plain text into your question. Going by the backtrace, you are using C++
std::thread
. Please give a Minimal, Complete, and Verifiable example of your code reproducing the error and retag your question to C++ if you are writing in C++. Also: What is the original error? I only see a backtrace.– user10605163
Dec 28 '18 at 8:05
i debug my program with core dump file, all i can see is PC goes into COEF(), i dont know what is COEF(), is it a default signal handler
– blithe
Dec 28 '18 at 8:34
i debug my program with core dump file, all i can see is PC goes into COEF(), i dont know what is COEF(), is it a default signal handler
– blithe
Dec 28 '18 at 8:34
i have checked my code, every thing is ok , i just wonder what is COEF()
– blithe
Dec 28 '18 at 8:47
i have checked my code, every thing is ok , i just wonder what is COEF()
– blithe
Dec 28 '18 at 8:47
gdb
is reporting your stack may be corrupt, so I am not sure you can actually trust the backtrace. It is also possible your program crashed twice, so you are looking at your signal handler crashing. There is not enough information to diagnose the issue, because you have not presented enough information to deduce how to reproduce the problem.– jxh
Dec 28 '18 at 9:46
gdb
is reporting your stack may be corrupt, so I am not sure you can actually trust the backtrace. It is also possible your program crashed twice, so you are looking at your signal handler crashing. There is not enough information to diagnose the issue, because you have not presented enough information to deduce how to reproduce the problem.– jxh
Dec 28 '18 at 9:46
|
show 6 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53955240%2flinux-program-cashed-with-message-pc-in-coef%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53955240%2flinux-program-cashed-with-message-pc-in-coef%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Did you forget to post the code?
– 4386427
Dec 28 '18 at 8:03
Please paste error messages as plain text into your question. Going by the backtrace, you are using C++
std::thread
. Please give a Minimal, Complete, and Verifiable example of your code reproducing the error and retag your question to C++ if you are writing in C++. Also: What is the original error? I only see a backtrace.– user10605163
Dec 28 '18 at 8:05
i debug my program with core dump file, all i can see is PC goes into COEF(), i dont know what is COEF(), is it a default signal handler
– blithe
Dec 28 '18 at 8:34
i have checked my code, every thing is ok , i just wonder what is COEF()
– blithe
Dec 28 '18 at 8:47
gdb
is reporting your stack may be corrupt, so I am not sure you can actually trust the backtrace. It is also possible your program crashed twice, so you are looking at your signal handler crashing. There is not enough information to diagnose the issue, because you have not presented enough information to deduce how to reproduce the problem.– jxh
Dec 28 '18 at 9:46