Wrong Import date format selection crashes Gnucash
Geert Janssens
geert.gnucash at kobaltwit.be
Sun Dec 11 18:27:08 EST 2016
Op zondag 11 december 2016 12:20:48 CET schreef John Ralls:
> > On Dec 11, 2016, at 11:32 AM, Robert Fewell <14ubobit at gmail.com> wrote:
> >
> > #15 0x00007ffff6c2431f in gnc_dmy2timespec_neutral (day=day at entry=2016,
> > month=month at entry=12, year=year at entry=2001)
>
> The problem seems pretty obvious...
>
> > at gnc-date.cpp:1251
> >
> > ---Type <return> to continue, or q <return> to quit---
> > #16 0x00007fffe038564d in parse_date_with_year (format=<optimized out>,
> > date_str=0x11f1220 "2016/12/01") at gnc-csv-model.c:212
> > #17 parse_date (date_str=0x11f1220 "2016/12/01", format=1) at
> > gnc-csv-model.c:304
>
> Here you're telling parse_date_with_year to use "d-m-y" with a y-m-d format,
> and so passing an invalid day to gnc_dmy2rimespec_neutral.
>
> I suspect that this is what led Geert to ask about invalid date values a few
> weeks ago. We don't want exceptions to leak out of C++ modules, so
> gnc_dmy2timespec_neutral (and every other call to a constructor in
> gnu-date.cpp) should be inside a try-catch block and catch should return an
> invalid result; callers should test for that result. C++ code should use
> GncDateTime directly and handle the exception.
Apparently Bob is adding code to the csv import directory. But that code is
still c. You probably saw my heads-up on his latest PR.
Bob, parse_date_with_year will be gone soon. I'm nearly finished with what I
intended to achieve with the csv importer and can then merge my work into
master. The function you will want to use is called parse_date in my branch,
in file gnc-trans-props.hpp.
Since you're now adding an importer for price data, the function will probably
have to move to a more generic support file. In fact it should be incorporated
in GncDateTime somewhere as discussed with John. But that was on IRC I
believe.
It's pretty late here now. If you need more details, just ask.
Geert
More information about the gnucash-devel
mailing list