segfault on customer report

John Ralls jralls at ceridwen.us
Mon Apr 25 10:20:29 EDT 2016


> On Apr 25, 2016, at 3:15 AM, will Snow <wsnow at gmx.com> wrote:
> 
>   Hi All,
> 
>   After running Reports -> business -> customer report gnucash has a
>   segfault (git master branch c739f4fae442e583389dd8c47100a38a06aac4c4)
> 
>   I'm interested in helping out with gnucash so looked a bit further. It
>   looks as though the segfault occurs when the get_slot method is run
>   because the book variable is empty.
> 
>   src/libqof/qof/qofbook.cpp
>   1194 KvpValue*
>   1195 qof_book_get_option (QofBook *book, GSList *path)
>   1196 {
>   1197     KvpFrame *root = qof_instance_get_slots(QOF_INSTANCE (book));
>   1198     Path path_v {KVP_OPTION_PATH};
>   1199     for (auto item = path; item != nullptr; item =
>   g_slist_next(item))
>   1200         path_v.push_back(static_cast<const char*>(item->data));
>   1201     return root->get_slot(path_v);
>   1202 }
>   After looking a bit deeper it seems that SWIG_MustGetPtr (see below)
>   returns null to arg1 (book) which is then passed to qof_book_get_option
>   resulting in qof_instance_get_slots returning null instead of an object
>   and then it segfaults when trying to run get_slots.
> 
>   I thought adding some sort of check on the root variable but that's
>   probably wrong and not solving the underlying problem? I'm not sure
>   where to go from here with regards to fixing the issue. Any pointers
>   would be helpful. Thanks.
> 
>   ./src/engine/swig-engine.c
>   static SCM
>   _wrap_qof_book_get_option (SCM s_0, SCM s_1)
>   {
>   #define FUNC_NAME "qof-book-get-option"
>     QofBook *arg1 = (QofBook *) 0 ;
>     GSList *arg2 = (GSList *) 0 ;
>     SCM gswig_result;
>     SWIGUNUSED int gswig_list_p = 0;
>     KvpValue *result = 0 ;
>     {
>       arg1 = (QofBook *)SWIG_MustGetPtr(s_0, SWIGTYPE_p_QofBook, 1, 0);
>     }
>     arg2 = gnc_scm_to_gslist_string(s_1);
>     result = (KvpValue *)qof_book_get_option(arg1,arg2);
>     gswig_result = gnc_kvp_value_ptr_to_scm(result);
> 
>     return gswig_result;
>   #undef FUNC_NAME

The problem is probably upstream of _wrap_qof_book_get_option(): Whatever is calling it from Scheme is likely passing a nullptr in s_0.  If Scheme isn't one of your languages please file a bug.

Regards,
John Ralls




More information about the gnucash-devel mailing list