Bug 39520 - crash-on exit after copy/paste
Summary: crash-on exit after copy/paste
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.4.1 RC2
Hardware: Other macOS (All)
: medium critical
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 31607 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-07-25 02:56 UTC by Michael Meeks
Modified: 2011-12-22 05:52 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meeks 2011-07-25 02:56:13 UTC
Apparently Mac specific, prolly due to atexit / destructor ordering - sometimes I wonder whether we should just _exit() from the main app instead of exiting ;-)






Process:         soffice [718]
Path:            /Applications/LibreOffice.app/Contents/MacOS/soffice
Identifier:      org.libreoffice.script
Version:         3.4.2 (???)
Code Type:       X86 (Native)
Parent Process:  launchd [212]

Date/Time:       2011-07-24 12:03:48.100 +0200
OS Version:      Mac OS X 10.7 (11A511)
Report Version:  9

Interval Since Last Report:          103720 sec
Crashes Since Last Report:           2
Per-App Interval Since Last Report:  34723 sec
Per-App Crashes Since Last Report:   2
Anonymous UUID:                      D4DA3D17-0A11-41FF-A72A-45B7ACEC5C00

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000065086028

VM Regions Near 0x65086028:
     mapped file            00000000210c2000-0000000021fa3000 [ 14.9M] 
rw-/rwx SM=COW  /System/Library/Fonts/AppleGothic.ttf
-->
     __TEXT                 000000008fe43000-000000008fe76000 [  204K] 
r-x/rwx SM=COW  /usr/lib/dyld

Application Specific Information:
objc[718]: garbage collection is OFF
Performing @selector(terminate:) from sender NSMenuItem 0x406e200

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libuno_cppu.dylib.3                 0x0036773a 
typelib_typedescriptionreference_getDescription + 76
1   introspection.uno.dylib             0x1e95a8e6 component_getFactory + 23510
2   introspection.uno.dylib             0x1e95edff component_getFactory + 41199
3   introspection.uno.dylib             0x1e961cf5 component_getFactory + 53221
4   libsbmxi.dylib                      0x01fff961 
SbUnoObject::doIntrospection() + 113
5   libsbmxi.dylib                      0x01ffffa8 SbUnoObject::getUnoAny() + 296
6   libsbmxi.dylib                      0x01fd6eb5 
StarBASIC::GetUNOConstant(char const*, com::sun::star::uno::Any&) + 165
7   libsbmxi.dylib                      0x01fda798 
DocBasicItem::stopListening() + 120
8   libsbmxi.dylib                      0x01fdaa6a 
DocBasicItem::~DocBasicItem() + 58
9   libsbmxi.dylib                      0x020c04c3 SbxHint::~SbxHint() + 227
10  libsystem_c.dylib                   0x93691944 __cxa_finalize + 243
11  libsystem_c.dylib                   0x936917f2 exit + 25
12  com.apple.AppKit                    0x945c17ef -[NSApplication 
terminate:] + 2497
13  com.apple.CoreFoundation            0x99fd2901 -[NSObject 
performSelector:withObject:] + 65
14  com.apple.AppKit                    0x946c5937 -[NSApplication 
sendAction:to:from:] + 232
15  com.apple.AppKit                    0x947b91a3 -[NSMenuItem 
_corePerformAction] + 536
16  com.apple.AppKit                    0x947b8e20 -[NSCarbonMenuImpl 
performActionWithHighlightingForItemAtIndex:] + 171
17  com.apple.AppKit                    0x947b84a9 -[NSMenu 
_performActionWithHighlightingForItemAtIndex:sendAccessibilityNotification:] 
+ 79
18  com.apple.AppKit                    0x947b8455 -[NSMenu 
_performActionWithHighlightingForItemAtIndex:] + 48
19  com.apple.AppKit                    0x94731c43 -[NSMenu 
performKeyEquivalent:] + 306
20  libvclmxi.dylib                     0x01a26eb2 SalGetDesktopEnvironment() 
+ 21506
21  libvclmxi.dylib                     0x01a22280 SalGetDesktopEnvironment() 
+ 2000
22  libvclmxi.dylib                     0x01716180 Application::Yield(bool) + 96
23  libvclmxi.dylib                     0x01716281 Application::Execute() + 97
24  libsofficeapp.dylib                 0x0006a785 0x58000 + 75653
25  libvclmxi.dylib                     0x0171e268 DeInitVCL() + 3624
26  libvclmxi.dylib                     0x01a2181b component_getFactory + 209547
27  libvclmxi.dylib                     0x01a26c4b SalGetDesktopEnvironment() 
+ 20891
28  com.apple.AppKit                    0x945b652b -[NSApplication run] + 1000
29  com.apple.AppKit                    0x94849b54 NSApplicationMain + 1054
30  libvclmxi.dylib                     0x01a225a7 SalGetDesktopEnvironment() 
+ 2807
31  libvclmxi.dylib                     0x0171e311 SVMain() + 17
32  libsofficeapp.dylib                 0x00096f65 soffice_main + 245
33  org.libreoffice.script              0x00001ebe main + 30
34  org.libreoffice.script              0x00001822 start + 258
35  org.libreoffice.script              0x00001749 start + 41

all other threads quiescent.

It looks like this is related to cleaning up:

basic/source/classes/sb.cxx's

static DocBasicItemMap GaDocBasicItems;

Which does:

DocBasicItem::~DocBasicItem()
{
    stopListening();
}

void DocBasicItem::stopListening()
{
    if( mbDisposed ) return;
    mbDisposed = true;
    Any aThisComp;
    mrDocBasic.GetUNOConstant( "ThisComponent", aThisComp );
    Reference< util::XCloseBroadcaster > xCloseBC( aThisComp, UNO_QUERY );
    if( xCloseBC.is() )
        try { xCloseBC->removeCloseListener( this ); } catch( uno::Exception& ) {}
}

I suspect the GetUnoConstant fun personally.
Comment 1 Michael Meeks 2011-07-25 04:23:31 UTC
Hmm - I *guess* that it is wedging on:

    MutexGuard aGuard( Init::get().getMutex() );

unless the rtl::Static pattern is safe (leaks) at destruction ?

So - perhaps something like this:


diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 6105d51..916e2c6 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -138,6 +138,8 @@ void DocBasicItem::stopListening()
 {
     if( mbDisposed ) return;
     mbDisposed = true;
+    if (!::comphelper::getProcessServiceFactory().is()) // in atexit;
+        return;
     Any aThisComp;
     mrDocBasic.GetUNOConstant( "ThisComponent", aThisComp );
     Reference< util::XCloseBroadcaster > xCloseBC( aThisComp, UNO_QUERY );

Might help - although it is not over-elegant, and I'm assuming that:

desktop/source/app/app.cxx's DeInit has been called.

Caolan - you have more experience of this - any thoughts ? :-)

[ and the trace looks odd too - almost as if OS/X called 'exit' for us, which is hard to believe ],
Comment 2 gerdl 2011-07-25 05:45:05 UTC
Please have a look at the file coming with Bug 39510 crash on exit with windows
g
Comment 3 Caolán McNamara 2011-07-25 06:49:41 UTC
I'd have to see some backtraces.

if something got inserted into that list, then it must have been added by lclInsertDocBasicItem.

at that point it should have registered itself as a CloseListener on some document, so if there are still entries in there at app shutdown time which do not have mbDisposed as true , then it suggests that DocBasicItem::stopListening() wasn't already called, given the 

    if( mbDisposed ) return;
    mbDisposed = true;

which suggests that the document didn't emit stopListening before exiting ? 

as a hackaround it might all go away if DocBasicItemMap is turned into a rtl::Static singleton rather than as a global one
Comment 4 Michael Meeks 2011-07-25 10:12:27 UTC
Pushed this to master:

commit b94deac0a3c528530f19ec65f2b1b8c899100941
Author: Michael Meeks <michael.meeks@novell.com>
Date:   Mon Jul 25 18:08:29 2011 +0100

    fdo#39520 - turn DocBasicItems into an rtl::Static to improve shutdown on mac

it'd be nice to know if a master build in a few days time address the issue, if so we'll back-port to libreoffice-3-4.
Comment 5 Caolán McNamara 2011-07-26 01:26:20 UTC
There's also a goodly chance that something of the nature of the SfxHint/SfxTypeHint RTTI bug that thorston found/fixed might be related to the apparent missing XCloseDocument events.
Comment 6 Caolán McNamara 2011-11-21 01:44:13 UTC
*** Bug 31607 has been marked as a duplicate of this bug. ***
Comment 7 Caolán McNamara 2011-11-21 01:45:40 UTC
we never cherry-picked this to 3-4, do we know if macosx is now happy in master with crash-on-exit post copy/paste ?
Comment 8 Caolán McNamara 2011-11-21 02:07:15 UTC
cmc->sb: this is the mac crash on exit again, except this time we have the extra info that its after a cut and paste
Comment 9 Michael Meeks 2011-11-21 02:14:32 UTC
Sure - it's a ~trivial patch; great to have in libreoffice-3-4: on master it is:

commit 0ee44dbd6f7921a70e2ddf039dc8a02b03129efd
Author: Michael Meeks <michael.meeks@novell.com>
Date:   Mon Jul 25 18:08:29 2011 +0100

    fdo#39520 - turn DocBasicItems into an rtl::Static to improve shutdown on mac
Comment 10 Caolán McNamara 2011-11-21 02:34:05 UTC
right, http://cgit.freedesktop.org/libreoffice/libs-core/commit/?h=libreoffice-3-4 for 3.4.5

If someone can find out if this works/fails on mac that'd be great, in the interim lets assume its "resolved" unless we find out to the contrary though I'm still concerned about possible missing stopListener.
Comment 11 Björn Michaelsen 2011-12-22 05:52:43 UTC
RESOLVED, FIXED or CLOSED bugs cant be KEYWORD NEEDINFO.