Crash in hbci online transfer in master due to GList of kvp_frame
Christian Stimming
christian at cstimming.de
Sun Jul 6 17:04:06 EDT 2014
Dear John,
thanks for the pointers. It seems like the import-export/aqb use case of kvp
was the only place in the code that used them this way, so this is probably
why neither you nor anyone else so far has stumbled over this problem.
I can't even easily send you a gnucash file for reproducing this problem,
because this very menu item can be called only if libaqbanking can already
verify an existing configured online banking setup for this gnucash account.
That means even if I send you my gnucash file, the menu items in question
won't be active on your machine because you don't have my libaqbanking setup.
The immediate error is that the book's kvp slot "hbci/template-list" (see
below for an example section of that slot from my data file) contains a value
that is a GList, and those list elements are again kvp slots. When those list
elements are asked to be converted from the kvp_value to GList elements in
gvalue_list_from_kvp_value(), it calls gvalue_from_kvp_value() but there the
"kval" argument is of type KVP_TYPE_FRAME that runs in the PWARN("Error!
Attempt to transfer KvpFrame!") and returns NULL, which in turn crashes in
kvp_frame.cpp:1677.
I think I was the only one who used this possibility to put a GList of
kvp_frames in the data file. At the time in 2003, I needed a GList of
GncABTransTempl objects (see src/import-export/aqb/gnc-ab-trans-templ.h and
.c) to be stored in the data file. The solution at the time was to put the
GncABTransTempl fields into the slots of a kvp_frame (see
gnc_ab_trans_templ_to_kvp and gnc_ab_trans_templ_new_from_kvp in that file),
and then putting those kvp_frames into a GList and this one in turn in a kvp
slot. Yes, I know it was against any form of data hiding, but that's what was
there at the time.
However, the data fields don't have to be touched often: This list of
GncABTransTempl must be read once when calling the "online transfer" menu
item, to populate the list of templates that can be used for the online
transfer. (i.e. the bank details for the transfer to "Some Recipient" should
be auto-filled when clicking on the item in the template list.) This list is
written again when closing the "online transfer" window, in gnc-ab-
transfer.c:65 and :66, if and only if the list of available templates has been
modified. Which is seldomly the case. Hence, no optimization whatsoever needs
to be in place.
How should I access a GList of a structured data type after your kvp changes,
when I shouldn't make this a glist of kvp_frames anymore? What would be a good
alternative? Thanks a lot in advance!
Regards,
Christian
Am Donnerstag, 26. Juni 2014, 16:15:02 schrieb John Ralls:
> On Jun 24, 2014, at 1:19 PM, Christian Stimming <christian at cstimming.de>
wrote:
> > Due to some messed-up set up of my local git clone I apparently haven't
> > updated my local working copy to our common master for several months. Now
> > that I did that, I discovered that the online transfer menu item ("send
> > online transfer") will crash in master but not in maint.
> > ...
> > To reproduce: If you have a working online banking setup and also some
> > stored transaction templates, clicking "Actions -> Online Actions ->
> > Online Transfer" will now immediately crash as shown below:
> >
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > gvalue_list_from_kvp_value (kval=<optimized out>, pList=0x7fffffffbcf0)
> > at ../../../../src/libqof/qof/kvp_frame.cpp:1677
> >
> > 1677 if (G_VALUE_TYPE (gval))
> > (gdb) bt
> > #0 gvalue_list_from_kvp_value (kval=<optimized out>,
> > pList=0x7fffffffbcf0)
> > at ../../../../src/libqof/qof/kvp_frame.cpp:1677
> >
> > #1 0x00007ffff608b648 in g_list_foreach (list=<optimized out>,
> > func=0x7ffff6ca1590 <gvalue_list_from_kvp_value(KvpValue*, gpointer)>,
> > user_data=0x7fffffffbcf0)
> > at /build/buildd/glib2.0-2.40.0/./glib/glist.c:993
<gnc:book version="2.0.0">
<book:id type="guid">0e823542dec06f29e58d8f1c086223e0</book:id>
<book:slots>
<!-- ... -->
<slot>
<slot:key>hbci</slot:key>
<slot:value type="frame">
<slot>
<slot:key>template-list</slot:key>
<slot:value type="list">
<slot:value type="frame">
<slot>
<slot:key>amou</slot:key>
<slot:value type="numeric">0/1</slot:value>
</slot>
<slot>
<slot:key>name</slot:key>
<slot:value type="string">Some Recipient</slot:value>
</slot>
<slot>
<slot:key>purc</slot:key>
<slot:value type="string"></slot:value>
</slot>
<slot>
<slot:key>purp</slot:key>
<slot:value type="string">my purpose lime</slot:value>
</slot>
<slot>
<slot:key>racc</slot:key>
<slot:value type="string">0519763065</slot:value>
</slot>
<slot>
<slot:key>rbcd</slot:key>
<slot:value type="string">50010517</slot:value>
</slot>
<slot>
<slot:key>rnam</slot:key>
<slot:value type="string">stimming, christian</slot:value>
</slot>
</slot:value>
<slot:value type="frame">
<slot>
<slot:key>amou</slot:key>
<slot:value type="numeric">100000/100</slot:value>
</slot>
<slot>
<slot:key>name</slot:key>
<slot:value type="string">Another recipient</slot:value>
</slot>
<slot>
<slot:key>purc</slot:key>
<slot:value type="string">a.u.c. stimming</slot:value>
</slot>
<slot>
<slot:key>purp</slot:key>
<slot:value type="string">another purpose line</slot:value>
</slot>
<slot>
<slot:key>racc</slot:key>
<slot:value type="string">6486773</slot:value>
</slot>
<slot>
<slot:key>rbcd</slot:key>
<slot:value type="string">20070024</slot:value>
</slot>
<slot>
<slot:key>rnam</slot:key>
<slot:value type="string">anne u. c. stimming</slot:value>
</slot>
</slot:value>
</slot:value>
</slot>
</slot:value>
</slot>
More information about the gnucash-devel
mailing list