Bug 132884 - Segmentation Fault after python+uno script closes in case desktop is not terminated
Summary: Segmentation Fault after python+uno script closes in case desktop is not term...
Status: RESOLVED INSUFFICIENTDATA
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
5.3.6.1 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-Python
  Show dependency treegraph
 
Reported: 2020-05-09 18:23 UTC by Suren Arustamyan
Modified: 2021-06-22 03:38 UTC (History)
1 user (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 Suren Arustamyan 2020-05-09 18:23:28 UTC
Description:
I'm trying to write xlsx to csv converter on python based on LibreOffice and uno library.
The idea is to convert all sheets into separate csv file.

When I run simple python script I'm getting Segmentation Fault error unless I'm terminating LibreOffice process from 'desktop' actively. 
However this way I will need to restart LibreOffice process every time which seems excessive and not really graceful. 

What I'm trying to achieve is to start LibreOffice as a daemon (using systemd) and connect/disconnect to this process from python once there is conversion task.

Probably I should close connection somehow explicitly, however I didn't find respective method so far. Could you please point me to the way I should do it if there is any?


Steps to Reproduce:
1.Run following python2 script:

#!/usr/bin/env python2

import os
import sys

import uno  
from com.sun.star.beans import PropertyValue
from com.sun.star.connection import NoConnectException

OPENOFFICE_PORT = 8100
OPENOFFICE_LIBPATH = '/usr/lib64/libreoffice/program'

if sys.path.count(OPENOFFICE_LIBPATH) == 0:
    sys.path.insert(0, OPENOFFICE_LIBPATH)

localContext = uno.getComponentContext()

resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)

context = resolver.resolve("uno:socket,host=127.0.0.1,port=%d;urp;StarOffice.ComponentContext" % OPENOFFICE_PORT)

desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)

# desktop.terminate()

Actual Results:
Segmentation fault

Expected Results:
no errors


Reproducible: Always


User Profile Reset: Yes



Additional Info:
In case I'll add 'desktop.terminate()' at the end there is no error but LibreOffice process closed.

Environment:
LibreOffice 5.3.6.1 30(Build:1) (from yum)
Vagrant, CentOS Linux release 7.6.1810 (Core)
Python 2.7.5

LibreOffice is running as a daemon using this command (via systemd):
/usr/lib64/libreoffice/program/soffice --headless \
     --accept=socket,host=127.0.0.1,port=8100;urp; --display :5.0 \
     --pidfile=/var/run/soffice.pid --nologo --nodefault --nofirststartwizard --norestore
Comment 1 Buovjaga 2020-08-31 17:53:01 UTC
You are using LibreOffice 5.3 and Python 2. Both are end of life. Please try with Python 3 and LibreOffice 7.0.
Comment 2 QA Administrators 2021-05-22 04:23:44 UTC Comment hidden (obsolete)
Comment 3 QA Administrators 2021-06-22 03:37:57 UTC
Dear Suren Arustamyan,

Please read this message in its entirety before proceeding.

Your bug report is being closed as INSUFFICIENTDATA due to inactivity and
a lack of information which is needed in order to accurately
reproduce and confirm the problem. We encourage you to retest
your bug against the latest release. If the issue is still
present in the latest stable release, we need the following
information (please ignore any that you've already provided):

a) Provide details of your system including your operating
   system and the latest version of LibreOffice that you have
   confirmed the bug to be present

b) Provide easy to reproduce steps – the simpler the better

c) Provide any test case(s) which will help us confirm the problem

d) Provide screenshots of the problem if you think it might help

e) Read all comments and provide any requested information

Once all of this is done, please set the bug back to UNCONFIRMED
and we will attempt to reproduce the issue. Please do not:

a) respond via email 

b) update the version field in the bug or any of the other details
   on the top section of our bug tracker

Warm Regards,
QA Team

MassPing-NeedInfo-FollowUp