Problems with Text::CSV_XS and t/Labels.t
My last install was on 3.10.02 and all was well with the set of Perl modules had then, which included Text::CSV_XS-0.85. As I prepared to build 3.10.06, I upgraded my Perl modules as some additions were required in any case. After the cpan upgrades, 'make test' was failing for both my 3.10.02 and 3.10.06 build trees. t/Labels.t would just exit after running the first sub-test (use). After a couple of days, I have tracked this down to a change in Text/CSV_XS.pm: *** Text-CSV_XS-0.85/blib/lib/Text/CSV_XS.pm 2011-09-07 12:34:16.000000000 +0100 --- .cpan/build/Text-CSV_XS-0.97-cJDgOc/blib/lib/Text/CSV_XS.pm 2013-03-30 14:58:47.000000000 +0000 *************** ... (in the subroutine 'parse') ... *************** *** 492,498 **** my $fflags = []; $self->{_STRING} = \$str; if (defined $str && $self->Parse ($str, $fields, $fflags)) { - $self->{_ERROR_INPUT} = undef; $self->{_FIELDS} = $fields; $self->{_FFLAGS} = $fflags; $self->{_STATUS} = 1; I further tracked this down to the most recent change (0.96 -> 0.97 around March 30th, 2013). The changelog says: diff Text-CSV_XS-0.96/ChangeLog .cpan/build/Text-CSV_XS-0.97-cJDgOc/ChangeLog 0a1,5
0.97 - 2013-03-30, H.Merijn Brand * Regain the speed from 0.91 (buffer back to 1k) * Minor cleanup in XS code * Add diag_verbose attribute
I guess this qualifies as a minor cleanup if you assume people won't call error_input on no error condition. The error from t/Labels.t is a segmentation fault when calling $csv->error_input() in Labels/Label.pm. sub _get_text_fields { my $format_string = shift; my $csv = Text::CSV_XS->new({allow_whitespace => 1}); my $status = $csv->parse($format_string); my @sorted_fields = map {{ 'code' => $_, desc => $_ }} map { $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653 $csv->fields(); my $error = $csv->error_input(); warn sprintf('Text field sort failed with this error: %s', $error) if $error; return \@sorted_fields; } I think there is an error here in _get_text_fields where it calls $csv->error_input() when there was no error. In the past, it would get an undef, but the the more recent CSV_XS.pm module, the attribute is not defined at all and it seg faults. I think error_input() should only be called if $status != 1. Comments? I think this is a Koha bug. Revertion to Text::CSV_XS-0.96 resolves the problem until we fix Koha. Regards, -Doug-
Hi, On Sun, Jun 2, 2013 at 2:08 PM, Doug Kingston <dpk@randomnotes.org> wrote:
I think there is an error here in _get_text_fields where it calls $csv->error_input() when there was no error. In the past, it would get an undef, but the the more recent CSV_XS.pm module, the attribute is not defined at all and it seg faults. I think error_input() should only be called if $status != 1.
Comments? I think this is a Koha bug.
I think it is also a bug in Text::CSV_XS -- at the very least, the module ought to just throw an exception rather than segfault if error_input() is called after a successful parse() -- but I agree that Koha should be checking for parsing errors in the way documented by the module's POD. Would you mind filing a bug at http://bugs.koha-community.org? Regards, Galen -- Galen Charlton Manager of Implementation Equinox Software, Inc. / The Open Source Experts email: gmc@esilibrary.com direct: +1 770-709-5581 cell: +1 404-984-4366 skype: gmcharlt web: http://www.esilibrary.com/ Supporting Koha and Evergreen: http://koha-community.org & http://evergreen-ils.org
Hi, On Sun, Jun 2, 2013 at 4:57 PM, Galen Charlton <gmc@esilibrary.com> wrote:
I think it is also a bug in Text::CSV_XS -- at the very least, the module ought to just throw an exception rather than segfault if error_input() is called after a successful parse() -- but I agree that Koha should be checking for parsing errors in the way documented by the module's POD.
I've filed a bug against Text::CSV_XS: https://rt.cpan.org/Ticket/Display.html?id=85810 Regards, Galen -- Galen Charlton Manager of Implementation Equinox Software, Inc. / The Open Source Experts email: gmc@esilibrary.com direct: +1 770-709-5581 cell: +1 404-984-4366 skype: gmcharlt web: http://www.esilibrary.com/ Supporting Koha and Evergreen: http://koha-community.org & http://evergreen-ils.org
Hi, On Sun, Jun 2, 2013 at 5:29 PM, Galen Charlton <gmc@esilibrary.com> wrote:
I've filed a bug against Text::CSV_XS:
The maintainer of the module has since fixed the bug and released an updated package, so updating should resolve the segfault issue. However, I've also opened Koha bug 10400 to improve how our code handles errors reported by Text::CSV_XS. [1] http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=10400 Regards, Galen -- Galen Charlton Manager of Implementation Equinox Software, Inc. / The Open Source Experts email: gmc@esilibrary.com direct: +1 770-709-5581 cell: +1 404-984-4366 skype: gmcharlt web: http://www.esilibrary.com/ Supporting Koha and Evergreen: http://koha-community.org & http://evergreen-ils.org
participants (2)
-
Doug Kingston -
Galen Charlton