[OpenWrt-Devel] uci_lookup_ptr() seg fault
bkil
bk.il.hU+ibLa_qUzy at gmail.com
Sat Feb 20 06:34:08 EST 2016
You can investigate a core dump file using gdb or an IDE to review the
call stack and variables (extra useful if compiled with -g and -O0).
You may need to enable core dumping like so:
http://www.idimmu.net/2013/06/21/enable-linux-core-dump/
http://www.akadia.com/services/ora_enable_core.html
By the way, if you get a segfault on the uci_lookup_ptr() line, you
probably have pkg==NULL, as returned by uci_load().
On Tue, Feb 16, 2016 at 7:12 PM, Farid Farid <farid21657 at yahoo.com> wrote:
> Hi All,
>
> I am getting seg fault sometimes on the uci_lookup_ptr() call. here is the
> way I call this function:
> It happens I would say once every couple of hundred calls.
> I appreciate if someone can help and guide me how to debug this issue.
> I have tried it with uci package from 2016-02-02
>
> char *
> get_uci_option_api (char* file_name , char* section_name , char*
> section_value , char* option_name)
> {
> struct uci_element *e;
> struct uci_section *s = NULL;
> struct uci_package *pkg;
> struct uci_context *m_uci;
> struct uci_ptr ptr;
>
> m_uci = uci_alloc_context();
> if (!m_uci)
> return NULL;
>
> uci_load ( m_uci , file_name , &pkg);
> memset(&ptr,0,sizeof(struct uci_ptr));
>
> ptr.option = NULL;
> ptr.section = section_value;
> ptr.package = file_name;
> ptr.value = section_name;
> if (!uci_lookup_ptr(pkg->ctx, &ptr , NULL , true))
> {
> s = ptr.s;
> }
> else
> s = NULL;
>
> if (!s)
> return NULL;
>
> uci_foreach_element (&s->options, e)
> {
> if (!strcmp (e->name, option_name))
> {
> struct uci_option *o = uci_to_option (e);
> if (o->type == UCI_TYPE_STRING)
> return o->v.string;
> }
> return NULL;
> }
>
> Thanks,
> Farid
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list