After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 724399 - xls export hangs
xls export hangs
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: import/export MS Excel (tm)
git master
Other All
: Normal major
: ---
Assigned To: Jody Goldberg
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2014-02-15 05:21 UTC by Andreas J. Guelzow
Modified: 2014-02-17 17:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sample gnumeric file (3.55 KB, application/x-gnumeric)
2014-02-15 05:21 UTC, Andreas J. Guelzow
  Details
Proposed patch (618 bytes, patch)
2014-02-15 19:55 UTC, Jean Bréfort
none Details | Review

Description Andreas J. Guelzow 2014-02-15 05:21:31 UTC
Created attachment 269166 [details]
sample gnumeric file

If I save the attached file as an xls file (MS Exceltm 97/2000/XP & 5.0/95) the export hangs. Interupting it always appears to result in the same location:

  • #0 write
    from /lib/x86_64-linux-gnu/libc.so.6
  • #1 _IO_file_write
    from /lib/x86_64-linux-gnu/libc.so.6
  • #2 ??
    from /lib/x86_64-linux-gnu/libc.so.6
  • #3 _IO_do_write
    from /lib/x86_64-linux-gnu/libc.so.6
  • #4 _IO_switch_to_get_mode
    from /lib/x86_64-linux-gnu/libc.so.6
  • #5 _IO_file_seekoff
    from /lib/x86_64-linux-gnu/libc.so.6
  • #6 fseeko64
    from /lib/x86_64-linux-gnu/libc.so.6
  • #7 gsf_output_stdio_seek
    at gsf-output-stdio.c line 356
  • #8 gsf_output_seek
    at gsf-output.c line 401
  • #9 gsf_output_seek
    at gsf-output.c line 401
  • #10 ms_biff_put_var_commit
    at ms-biff.c line 709
  • #11 ms_biff_put_commit
    at ms-biff.c line 754
  • #12 excel_write_string
    at ms-excel-write.c line 382
  • #13 excel_write_value
    at ms-excel-write.c line 3253
  • #14 excel_write_cell
    at ms-excel-write.c line 3535
  • #15 excel_sheet_write_block
    at ms-excel-write.c line 5269
  • #16 excel_write_sheet
    at ms-excel-write.c line 5451
  • #17 excel_write_workbook
    at ms-excel-write.c line 6303
  • #18 excel_write_v7
    at ms-excel-write.c line 6334
  • #19 excel_save
    at boot.c line 279
  • #20 go_plugin_file_saver_save
    at app/go-plugin-service.c line 948
  • #21 wbv_save_to_output
    at workbook-view.c line 1059

The obvious guess is that something is going wrong with "into Back Corté"
Comment 1 Morten Welinder 2014-02-15 16:12:54 UTC
It's the Excel95 saving that goes crazy.  It can be triggers like this:

./ssconvert -T Gnumeric_Excel:excel_biff7 ~/Download/tango-gold.gnumeric /tmp/ttt.xls
Comment 2 Andreas J. Guelzow 2014-02-15 17:16:00 UTC
Note that this problem does not occur with Gnumeric 1.12.6. If I recall correctly then since 1.12.6 the string export to xls was changed.
Comment 3 Morten Welinder 2014-02-15 18:12:08 UTC
The problem arose with the patch for bug 715110.

Jean:

(gdb) p avail
$18 = 1
(gdb) p offset
$19 = 0
(gdb) p out_bytes
$20 = 17
(gdb) p tmp
$21 = 0x637ea0 "\351~c"
(gdb) p tmp-10
$22 = 0x637e96 " Back Cort\351~c"

When we do...
			avail = MIN (avail, output_len);
			avail = (avail - offset) / 2 * 2 + offset; /* we need to export an even byte number */

...we end up with avail==0 and see no progress.

Jean: where did "we need to export an even byte number" come from?  Does it
apply to pre-BIFF8?
Comment 4 Jean Bréfort 2014-02-15 18:57:55 UTC
I don't remember, as usual, not enough comments. May be it's just wrong.
Comment 5 Jean Bréfort 2014-02-15 19:55:40 UTC
Created attachment 269224 [details] [review]
Proposed patch

May be we need to have an even number of chars only if we split the string and never for the last run.
Comment 6 Morten Welinder 2014-02-15 21:58:04 UTC
What we need is a test suite covering strings.  From a QA point-of-view
we shouldn't be able to make this kind of mistake.

I think we can do this by round-trip testing:

gnumeric -> biff7 -> gnumeric
gnumeric -> biff8 -> gnumeric
gnumeric -> ods -> gnumeric
gnumeric -> xlsx -> gnumeric

...using a file containing (at least)

1. Simple short ascii strings.  Odd and even lengths.
2. A very long (say, 10k characters) ascii string.
3. A short non-ascii string.
4. A very long non-ascii string.
5. A very long non-ascii string with the first (say) 4k being ascii.
6. Ditto with the final 4k characters.
7. An empty string
8. A selection of far-east language strings.
9. Non-ascii strings with ISO-8859-1 representation.  Odd and even lengths.
Comment 7 Morten Welinder 2014-02-16 15:01:17 UTC
Tests are in: t6500-strings.pl

Without patch, we get a hang.  With patch, we get criticals:

| (/home/welinder/gnome/gnumeric/src/.libs/lt-ssconvert:18729): gnumeric:read-WA
RNING **: File is most likely corrupted.
| (Condition "q->length - 8 >= in_len" failed in excel_read_LABEL.)

These appear to relate to all the long strings.
Comment 8 Morten Welinder 2014-02-16 15:16:39 UTC
I am tempted to release a new version today with or without fixes for the
long-string issue.  I don't think that issue is new.
Comment 9 Jean Bréfort 2014-02-16 16:08:15 UTC
not new, but a bit critical, at least for people using .xls. We probably also need to adjust the saved length (just guessing).
Comment 10 Morten Welinder 2014-02-16 16:22:16 UTC
The majority of the biff7 streams we write are never read.  They sit in
dual-format streams and only the biff8 is ever read.  The hang is much,
much worse.
Comment 11 Jean Bréfort 2014-02-16 17:06:33 UTC
LOcalc correctly imports the xls file we export with the long strings, so this is an issue with our import code. I'd vote for applying the patch, and fix the read code when possible.
Comment 12 Morten Welinder 2014-02-16 17:08:30 UTC
The problem might be on the read side, i.e., we may not handle BIFF_LABEL_v2
with continuation records right.

LO can read the files we produce, but truncates the strings at ~2k characters.
I think they fails to consider multiple continuation records.

I'll have to check if XL can read our files.



Biff read code 0x204, length 8
Opcode 0x204 length 8 malloced? 0
Data:
       0 | 05 00 01 00 17 00 10 27 XX XX XX XX XX XX XX XX | .......'********

(/home/welinder/gnome/gnumeric/src/.libs/lt-ssconvert:21777): gnumeric:read-WARN
ING **: File is most likely corrupted.
(Condition "q->length - 8 >= in_len" failed in excel_read_LABEL.)

Biff read code 0x3c, length 2078
Opcode 0x3c length 2078 malloced? 0
Data:
       0 | 61 62 63 64 61 62 63 64 61 62 63 64 61 62 63 64 | abcdabcdabcdabcd
      10 | 61 62 63 64 61 62 63 64 61 62 63 64 61 62 63 64 | abcdabcdabcdabcd
      20 | 61 62 63 64 61 62 63 64 61 62 63 64 61 62 63 64 | abcdabcdabcdabcd
      30 | 61 62 63 64 61 62 63 64 61 62 63 64 61 62 63 64 | abcdabcdabcdabcd
Comment 13 Morten Welinder 2014-02-16 17:12:34 UTC
Patch pushed.
Comment 14 Morten Welinder 2014-02-17 00:10:09 UTC
Excel is happy with the xls we create, so LO is buggy too.
Comment 15 Jean Bréfort 2014-02-17 14:21:02 UTC
The even byte number is a necessity in the unicode case. But not in other cases.
Comment 16 Morten Welinder 2014-02-17 17:16:23 UTC
The read side of v7 labels has been fixed.

Let's consider this fixed.  Any fallout from the tests should get their
own bugs.