Issue 3360 - Main Memory Shortage on MS Word doc open
Summary: Main Memory Shortage on MS Word doc open
Status: CLOSED FIXED
Alias: None
Product: General
Classification: Code
Component: code (show other issues)
Version: 641
Hardware: Sun Solaris
: P3 Trivial (vote)
Target Milestone: ---
Assignee: michael.ruess
QA Contact: issues@sw
URL: http://www.sfu.ca/~cdemwell/OOBug.doc
Keywords:
: 4233 7775 (view as issue list)
Depends on:
Blocks:
 
Reported: 2002-03-05 22:56 UTC by Unknown
Modified: 2002-11-29 09:45 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
MS Word document that replicates the crash (20.00 KB, application/MSWord)
2002-03-05 22:58 UTC, Unknown
no flags Details
patch to so3\source\inplace\embobj.cxx (741 bytes, patch)
2002-04-08 12:49 UTC, caolanm
no flags Details | Diff
new[] --> delete[] (844 bytes, patch)
2002-05-15 16:27 UTC, caolanm
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Unknown 2002-03-05 22:56:56 UTC
A "very small" MS Word document containing two MS Equation 3.0 objects and some
text crashes OO on opening. The error message "Main Memory Shortage. Please quit
other applications or close some windows before continuing" appears, and OO
comes down hard ("An Unrecoverable error has occurred"). This problem is evident
on Windows 98 SE on an Athlon XP system and Solaris 8 on an UltraSPARC 30. The
URL points to a document which will reproduce this error (20k).

Removing the equations OR the text below them seems to stop the error; the
equations are usually not properly displayed in either case however. Note the
document opens OK in Word 97 or Word 2k.
Comment 1 Unknown 2002-03-05 22:58:09 UTC
Created attachment 1157 [details]
MS Word document that replicates the crash
Comment 2 matthias.huetsch 2002-03-06 10:15:54 UTC
Reproducable if there's less than 1.1GB of memory:

The original request size (decimal + hexadecimal)
 - rtl_allocateMemory(unsigned long 1157627904)
 - rtl_allocateMemory(unsigned long 0x45000000)

Here's the stack trace:

SAL3! osl_assertFailedLine + 246 bytes
__rtl_memory_dequeue(__rtl_memory_desc_st * * 0x0012c4f4, unsigned int
1157627912) line 1002 + 28 bytes
rtl_allocateMemory(unsigned long 1157627912) line 1467 + 13 bytes
TL641MI! operator new(unsigned int) + 58 bytes
SOT641MI! ReadClipboardFormat(class SvStream &) + 82 bytes
SOT641MI! StgCompObjStream::Load(void) + 295 bytes
SOT641MI! Storage::GetClassName(void) + 31 bytes
SOT641MI! SotStorage::GetClassName(void) + 150 bytes
SO641MI! SvStorage::GetClassName(void) + 93 bytes
SO641MI! SvFactory::CreateAndLoad(class SvStorage *,unsigned char) +
100 bytes
DL641MI! SvxMSDffManager::CreateSdrOLEFromStorage(class String const
&,class SvStorageRef &,class SvStorageRef &,class Graphic const
&,class Rectangle const &,class SvStream *,unsigned long) + 2821 bytes
SW641MI! SwWW8ImplReader::ImportOleBase(class Graphic &,unsigned
char,class Graphic const *,class SfxItemSet const *) + 1354 bytes
SW641MI! SwWW8ImplReader::ImportOle(class Graphic const *,class
SfxItemSet const *) + 94 bytes
SW641MI! SwWW8ImplReader::ImportGraf(class SdrTextObj *,class SwFrmFmt
*,unsigned char) + 1877 bytes
SW641MI! SwWW8ImplReader::ReadChar(long,long) + 641 bytes
SW641MI! SwWW8ImplReader::ReadChars(long &,long,long,long) + 77 bytes
SW641MI! SwWW8ImplReader::ReadText(long,long,short) + 416 bytes
SW641MI! SwWW8ImplReader::LoadDoc1(class SwPaM &,class WW8Glossary *)
+ 2731 bytes
SW641MI! SwWW8ImplReader::LoadDoc(class SwPaM &,class WW8Glossary *) +
799 bytes
Comment 3 stefan.baltzer 2002-03-06 12:33:59 UTC
Reassigned to Michael.
Comment 4 matthias.huetsch 2002-04-05 19:25:22 UTC
Hi Caolan,

just guessing but could you have a look at this, please, and then
assign to the responsible developer?

To me, this looks like a 'byte reversal' of the length field, but not
an endianess issue (same effect on X86 [little endian] and SPARC [big
endian]).

Thanks,
Matthias
Comment 5 caolanm 2002-04-08 12:49:28 UTC
Created attachment 1343 [details]
patch to so3\source\inplace\embobj.cxx
Comment 6 caolanm 2002-04-08 13:11:33 UTC
Well its not the ww8 filters fault anyway, the finger of death points
towards so3 or sot. The attached patch would fix this particular
bugdoc but theres still an underlying problem of some kind.

cmc->mba: Methinks this bundle of joy is for you...

i.e. in so3/source/inplace/embobj.cxx SvEmbeddedObject::ConvertToOle2
has a table of recognized ole types for some sort of "flattened" ole
tree which it uses to set the class id (or something of that nature)
of an expanded ole tree made from the flattened version. When it
doesn't find a recognized type it is setting an empty type and on
reloading this tree in sot ReadClipboardFormat ends up with a bad length.

The attached patch makes the Equation 3.0 type a recognized type so
that the bug doesn't get triggered, but thats not really the true
problem. Theres either something not working with the idea of setting
an empty class type for the object on line 1502 with
rDest->SetClass( SvGlobalName(), nCbFmt, aSvrName ); 
or sot is getting confused on loading such a type, or there's some
interaction with a preexisting compobj stream in the flattened version.
Comment 7 Mathias_Bauer 2002-04-23 13:56:13 UTC
I will have a look on it later.
Comment 8 Mathias_Bauer 2002-04-23 13:57:05 UTC
-
Comment 9 caolanm 2002-05-15 15:47:15 UTC
*** Issue 4233 has been marked as a duplicate of this issue. ***
Comment 10 caolanm 2002-05-15 15:50:54 UTC
cmc->mba: The patch attached to issue 4233 is pretty much the true
solution to this, i'll leave it up to framework to apply it and see if
theres other like it to be fixed.

<waffle...>
The original clipboard name of the object is stored null terminated, 
and a count is prepended which includs this byte. The len is read, and
  buffer of equal len alloced and read into. This buffer up to and
including the 0 terminator* is assigned to a string.

At a later stage this string is written back as a clipboard name, i.e.
back to a byte sequence with its len prepended. Its written to disk up
to the first 0. But the String.Len() returns the size of the buffer,
which is the len of the string plus 1 for the redundant extra 0. One
is added to this value and prepended to the string. So the final
string len is prepended 1 too large.

The problem doesn't arise if the name is a recognized one because then
the string constructor without len argument is used.

There are likely to be more issues like this in our codebase, perhaps
we should consider modifying the String class to warn when a 0 value
is stored as the last char (or any char)
</waffle>
Comment 11 caolanm 2002-05-15 16:27:49 UTC
Created attachment 1661 [details]
new[] --> delete[]
Comment 12 caolanm 2002-07-24 11:18:26 UTC
Working now in SRX643m
Comment 13 michael.ruess 2002-07-24 15:26:47 UTC
Will work with OpenOffice 643 release. 
Comment 14 michael.ruess 2002-09-19 12:10:22 UTC
*** Issue 7775 has been marked as a duplicate of this issue. ***
Comment 15 michael.ruess 2002-11-29 09:45:35 UTC
Should work well in OpenOffice 643C