Issue 14041 - Crash when close generated Draw document while Macro still running
Summary: Crash when close generated Draw document while Macro still running
Status: CLOSED FIXED
Alias: None
Product: Draw
Classification: Application
Component: code (show other issues)
Version: OOo 1.1 Beta
Hardware: PC Windows XP
: P2 Trivial (vote)
Target Milestone: OOo 2.0
Assignee: stephan.wunderlich
QA Contact: issues@udk
URL: http://kosh.datateamsys.com/~danny/OO...
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-02 23:55 UTC by dannyb
Modified: 2004-04-21 16:11 UTC (History)
1 user (show)

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


Attachments
Draw document with macro that exhibits bug OOo1-1beta WinXP (17.83 KB, application/OOoDrawing)
2003-05-02 23:57 UTC, dannyb
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description dannyb 2003-05-02 23:55:52 UTC
Here is a Draw document that reproduces the bug.

http://kosh.datateamsys.com/~danny/OOo/BugAttachment/ColorWheel-20030502-4.sxd

Open the draw doc.  Click the button "Start Bouncing Ball".  A new drawing 
appears, with a bouncing ball.  (The ball will only bounce for 30 seconds, and 
is then programmed to time out.)  Before the 30 second timeout, close the new 
drawing with the animated bouncing ball.  OOo 1.1-beta crashes on Win XP.

Closing the new auto-generated drawing, while a macro is still trying to 
manipulate objects on that drawing is likely the underlying cause.  Closing the 
drawing should at least cause the macro to get a runtime error.  Even better 
would be if there were some capability such that the Macro could be written to 
detect the problem and react gracefully.
Comment 1 dannyb 2003-05-02 23:57:49 UTC
Created attachment 6013 [details]
Draw document with macro that exhibits bug OOo1-1beta WinXP
Comment 2 kay.ramme 2003-05-05 08:18:58 UTC
Andreas, I can reproduce this also on Linux. Please take a look
at it.
Comment 3 ab 2003-05-05 13:42:29 UTC
Changed to P2 because of crash.
In this situation Basic just accesses an object that is already
dead (although Basic holds a reference to it!). I have no idea how
Basic should avoid this because Basic is not notified that the
document it belongs to and is working on is closed.
->MBA: I think a document with a running Basic must not be closed.
You told me that Basic cannot be ask if a document's Basic is 
currently running. That's right, but it would be / have been easy 
to implement a corresponding method. I simply did not know that is 
was needed. In any case I see no way to fix this in Basic. Do you 
have any other idea?
Comment 4 Mathias_Bauer 2003-05-07 11:17:29 UTC
Closing views is now prevented if any macro is running
Fixed in CWS fwk02
Comment 5 Mathias_Bauer 2003-05-07 11:19:12 UTC
Forgot to set the right target :-)
Comment 6 Mathias_Bauer 2003-05-14 13:13:34 UTC
@tm: Please verify
Comment 7 thorsten.martens 2003-05-14 14:09:16 UTC
TM: Checked and verified in cws fwk02 -> OK !
Comment 8 thorsten.martens 2003-05-14 14:24:11 UTC
.
Comment 9 atr 2003-07-16 15:46:26 UTC
Atr: also fixed in current version.
Comment 10 kai.sommerfeld 2003-08-25 10:46:04 UTC
We discussed the problem again and came to the conclusion that the
provided fix  is not acceptable. It is not okay to disable closing of
any documents as long as StarBasic is active. This simply breaks
senseful functionality. The document that cannot be closed might be
completely unrelated to the running StarBasic. We need a real fix in
the drawing application here. Reopening issue.
Comment 11 kai.sommerfeld 2003-08-25 10:50:44 UTC
Submitted #i18622# for removal of original fix (target: OOo 1.1.1).
Reassigning task to drawing team. Resetting target milestone.


Comment 12 thomas.benisch 2003-08-25 11:46:37 UTC
The office crashes in SdGenericDrawPage::getPropertyValue().
The problem is, that the SdGenericDrawPage is a UNO component,
which is not disposed yet, but the internal C++ structure is
already destroyed, especially the pPage member of the SvxDrawPage
in this case.

When the document is closed, the C++ drawing view and the C++ drawing
model are destroyed. But the running StarBasic still has a reference
to the UNO component which represents the document. Therefore
the UNO document component should be destroyed only after the last
UNO reference to it has been released. It seems that the internal
C++ reference counting and the UNO reference counting differ.
A C++ drawing model may have several C++ drawing views.
After the last C++ drawing view is destroyed, the C++ drawing
model is destroyed. It seems that the UNO reference counting
is neglected at all.

In summary, this bug should be fixed in that way, that the UNO
document component and consequently all its internal C++ structures
are only destroyed after the last reference is released.

One can also think about disposing the UNO wrappers in the drawing
view/model destructors. If then StarBasic calls an API method of a
disposed UNO component, a DisposedException is thrown which will
be handled by StarBasic. This probably fixes the crash, but the 
problem with the wrong UNO reference counting remains.

For Geordi PP1 the following scenario seems to be the right way.
The initial fix for this task will be removed. This allows, that
a document can be closed via UI, even if StarBasic is running.
The crash can be avoided, if the StarBasic programmer implements an
event listener which will be registered at the document component.
When the document is closed, the listener will be notified and
StarBasic can be stopped with the 'Stop' command. See a code example
below.


Sub BouncingBall()

  ...
	
  ' Create a new Draw document
  Dim oDrawDoc As Object
  oDrawDoc = MakeNewDrawDoc()

  ' Add an event listener
  Dim oListener
  oListener = CreateUnoListener( "DrawDocListener_",
                                 "com.sun.star.lang.XEventListener" )
  oDrawDoc.addEventListener( oListener )

  ' Bounce the ball
  ...

  ' Remove the event listener
  oDrawDoc.removeEventListener( oListener )

End Sub


Sub DrawDocListener_disposing( oEvent )

  ' Stop the execution of the running StarBasic
  Stop
	
End Sub
Comment 13 Armin Le Grand 2003-09-12 13:29:16 UTC
AW->CL: This needs to be implemented in the UNO API.
Comment 14 dankegel 2003-09-30 05:42:21 UTC
Kay reproduced it, so it's confirmed...
Comment 15 clippka 2003-09-30 12:25:16 UTC
I will recheck the sd API that it handles destroyed core
implementations correctly
Comment 16 clippka 2004-03-16 09:35:47 UTC
Draw and Impress now throw DisposedException when api calls are made to
components that are disposed
Comment 17 clippka 2004-03-16 09:36:26 UTC
somehow the buttons from the testfile do not work in a current release, but you
can start the bouncing ball macro for testing by hand
Comment 18 stephan.wunderlich 2004-03-16 12:43:09 UTC
SW->CL: as seen the crash still occurs in cws_impress5ea1
Comment 19 clippka 2004-03-25 22:01:23 UTC
The original crash was fixed, the resulting crash caused by another fix in this
cws that only happens if accessibility support is on. this is now fixed
Comment 20 stephan.wunderlich 2004-03-29 11:33:16 UTC
SW: fixed in cws_impress5ea1
Comment 21 stephan.wunderlich 2004-03-29 11:34:21 UTC
SW: works as expected in cws_impress5ea1 => verified
Comment 22 stephan.wunderlich 2004-04-21 16:11:22 UTC
SW: ok in src680_m35 => closed