[BBB]] segfault when trying to run compiled zbar example

This forum is for topics dealing with problems with software specifically in the ARMv7h repo.

[BBB]] segfault when trying to run compiled zbar example

Postby redlotus » Mon Feb 09, 2015 6:18 pm

I tried to make a simple program from zbar example code and compiled it successfully. However, when I try to run, it throws Segmentation fault (core dumped) error though I try with same code on laptop, it just works fine. Any suggestions?
Extra information:
*I have installed zbar

My code (demo.c):
$this->bbcode_second_pass_code('', '
#include <stdio.h>
#include <zbar.h>

static void my_handler (zbar_image_t *image,
const void *userdata)
{
/* extract results */
const zbar_symbol_t *symbol = zbar_image_first_symbol(image);
for (; symbol; symbol = zbar_symbol_next(symbol))
{
/* TODO do something useful with results */
zbar_symbol_type_t typ = zbar_symbol_get_type(symbol);
const char *data = zbar_symbol_get_data(symbol);
printf("decoded %s symbol \"%s\"\n",
zbar_get_symbol_name(typ), data);
}
}

int main (int argc, char **argv)
{

/* TODO find out the default device */
const char *device = "/dev/video0";

/* setup zbar library standalone processor */
zbar_processor_t *proc = zbar_processor_create(1);

/* configure the processor */
zbar_processor_set_config(proc, 0, ZBAR_CFG_ENABLE, 1);

/* initialize the processor */
if (argc > 1)
device = argv[1];
zbar_processor_init(proc, device, 1);
/* resolution is limited to 240x320 */
zbar_processor_request_size(proc, 320, 240);

/* setup a callback */
zbar_processor_set_data_handler(proc, my_handler, NULL);

/* disable the preview window */
zbar_processor_set_visible(proc, 0);
/* start video */
zbar_processor_set_active(proc, 1);

/* keep scanning until user provides key/mouse input */
zbar_processor_user_wait(proc, -1);

/* clean up */
zbar_processor_destroy(proc);

return (0);
}
')

Compile with gcc (on board):
$this->bbcode_second_pass_code('', 'gcc -Wall -g -O2 -lzbar -mtune=cortex-a8 -march=armv7-a demo.c -o demo')
Also try
$this->bbcode_second_pass_code('', 'gcc -Wall -g -lzbar demo.c -o demo')

gdb
$this->bbcode_second_pass_code('', '
(gdb) run
Starting program: /root/zbar_demo/demo
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0xb6d0fa68 in XUnmapWindow () from /usr/lib/libX11.so.6
(gdb) backtrace
#0 0xb6d0fa68 in XUnmapWindow () from /usr/lib/libX11.so.6
#1 0xb6fbde18 in ?? () from /usr/lib/libzbar.so.0
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
')

Thanks in advance
P/s Sorry for my bad english.
redlotus
 
Posts: 1
Joined: Mon Feb 09, 2015 8:36 am

Return to ARMv7h

Who is online

Users browsing this forum: No registered users and 4 guests