Bug 158358 - DoS + Bad crash when killing Python macro
Summary: DoS + Bad crash when killing Python macro
Status: RESOLVED INVALID
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.6.3.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Crash
  Show dependency treegraph
 
Reported: 2023-11-24 14:52 UTC by LOO Debugger
Modified: 2025-08-14 18:50 UTC (History)
2 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 LOO Debugger 2023-11-24 14:52:49 UTC
Hello

I'm trying to learn how to create a macro in LibreOffice (7.6.3.2 60(Build:2)) under Linux.

I hit "run" on a Python macro that was calling an external software using "subprocess.check_output". This external tools never ended. So I killed LOo with xkill.

Now, every time I hit the Tools>Macro>Run or Tools>Macro>Organize>Python LOo crashes.

I've tried killing/restarting LOo multiple times, I get the same result. I tried killing any remaining all the processes I could find related to LOo or Python, with no luck... The only thing I didn't try is restart the computer, because I can't do it for the moment (important stuff runnning).

The error message when running LOo from CLI is:
""
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
""

So there might be bad (exploitable?) stuff happening here :( At least, it's a complete DoS for all Macros...
Comment 1 m_a_riosv 2023-11-25 03:45:42 UTC
Please, can you put your question in:
https://ask.libreoffice.org/c/english/5
There are people with a great acknowledge on python macros.
Comment 2 Werner Tietz 2023-11-25 07:24:37 UTC
Hallo

For now you should rename (backup) your user-profile and start soffice with a new user-profile from scratch. 

For the future:
dont execute **long running independent things** via »subprocess.check_output(…)
use »subprocess.Popen(…)« instead!
Comment 3 Buovjaga 2025-08-14 18:50:07 UTC
(In reply to Werner Tietz from comment #2)
> Hallo
> 
> For now you should rename (backup) your user-profile and start soffice with
> a new user-profile from scratch. 
> 
> For the future:
> dont execute **long running independent things** via
> »subprocess.check_output(…)
> use »subprocess.Popen(…)« instead!

Indeed: https://docs.python.org/3/library/subprocess.html#using-the-subprocess-module

"The recommended approach to invoking subprocesses is to use the run() function for all use cases it can handle. For more advanced use cases, the underlying Popen interface can be used directly."

I guess we can close this.