Bug 163219 - ScriptForge library crash
Summary: ScriptForge library crash
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
24.8.2.1 release
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:25.2.0 target:24.8.3
Keywords: regression
: 163408 (view as bug list)
Depends on:
Blocks: ScriptForge
  Show dependency treegraph
 
Reported: 2024-09-30 14:10 UTC by cdubs999
Modified: 2024-10-14 07:34 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
Sreenshot of error message (253.47 KB, image/png)
2024-09-30 14:10 UTC, cdubs999
Details
Sample file with macro (12.22 KB, application/vnd.oasis.opendocument.spreadsheet)
2024-09-30 14:59 UTC, Rafael Lima
Details
My macro test file (10.42 KB, application/vnd.oasis.opendocument.spreadsheet)
2024-09-30 16:25 UTC, cdubs999
Details
Error without SF error trapping (327.17 KB, image/png)
2024-09-30 16:45 UTC, Jean-Pierre Ledure
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cdubs999 2024-09-30 14:10:24 UTC
Created attachment 196796 [details]
Sreenshot of error message

Error message received when running a BASIC macro that defines and executes a progress bar.

LibreOffice version 24.2.6.2 works fine
Comment 1 raal 2024-09-30 14:43:00 UTC
Please attach test file. Thank you.
Comment 2 Rafael Lima 2024-09-30 14:59:04 UTC
Created attachment 196797 [details]
Sample file with macro

I create a minimal test file.

Repro with

Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 3d515f22100f2db75ab487e2909fa22c9574f0f1
CPU threads: 16; OS: Linux 6.8; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Calc: CL threaded

Works fine in

Version: 24.2.5.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 16; OS: Linux 6.8; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Ubuntu package version: 4:24.2.5-0ubuntu0.24.04.2
Calc: threaded
Comment 3 Rafael Lima 2024-09-30 14:59:44 UTC
@JPL can you please take a look at this one?
Comment 4 cdubs999 2024-09-30 16:25:04 UTC
Created attachment 196798 [details]
My macro test file

Test file attached but it's basically the same as your attachment 196797 [details].
Both files work OK on version 24.2.6.2 but neither of them work on version 24.8.2.1
Comment 5 Jean-Pierre Ledure 2024-09-30 16:45:33 UTC
Created attachment 196799 [details]
Error without SF error trapping
Comment 6 Jean-Pierre Ledure 2024-09-30 16:54:30 UTC
I confirm the bug with (downloaded today):

Version: 24.8.2.1 (X86_64) / LibreOffice Community
Build ID: 0f794b6e29741098670a3b95d60478a65d05ef13
CPU threads: 6; OS: Linux 5.15; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fr-BE (en_US.UTF-8); UI: en-US
Calc: threaded

I change the status to NEW.

My first idea was that it was a duplicate of bug#162962. But it is not. The latter bug is fixed in the actual 24.8 version.

It is however similar as it also happens inside a With statement.

The root cause does not seem to be searched in the ScriptForge code in the first place.

I will investigate further and try to establish what can be specific to this With block that might cause the error.
Comment 7 Jean-Pierre Ledure 2024-09-30 17:10:57 UTC
The root cause IMHO is that the error happens when the With block variable receives its content inside the With block.

Next code aborts in the same way (in 24.8+ only, not in 24.2):

Sub TryWith()
	Set a = Nothing
	With a
		If IsNull(a) Then a = ThisComponent
		b = .CurrentController
	End With
End Sub

I can agree that this is not a very elegant practice ... and I am ready to propose a workaround in the ScriptForge code, if relevant.

But shouldn't the Basic interpreter be tolerant to this With block structure ?
Comment 8 Rafael Lima 2024-09-30 17:23:02 UTC
(In reply to Jean-Pierre Ledure from comment #7)
> But shouldn't the Basic interpreter be tolerant to this With block structure
> ?

I agree that this may not be elegant... but changing this behavior in the "With" may break other macros as well (extensions, user macros).

I'm CC'ing Mike for some input about this. This sounds related to the issue in bug 162962.
Comment 9 Mike Kaganski 2024-10-06 05:32:13 UTC
This one is tricky ... I don't immediately see how to fix, other than reverting f3f46b5fe729876d128f63f7ab158954ab6657d7.

Jean-Pierre Ledure: please do apply the workaround now, and please allow some time to consider possible fix. It is definitely a bug; it definitely needs to be fixed. Just not easy to fix in the frame of the current idea of the bug 132064, which was "make it backward-compatible": the current implementation tries to make compiled Basic binaries with WITH to keep working in older LO versions: that is needed to allow password-protected Basic libraries work there. Indeed, re-implementing the WITH from scratch would allow me to do whatever is needed - except that backward compatibility.
Comment 10 Jean-Pierre Ledure 2024-10-06 08:58:52 UTC
(In reply to Mike Kaganski from comment #9)
> Jean-Pierre Ledure: please do apply the workaround now, and please allow
> some time to consider possible fix.

Will do. Thanks for feedback.
Comment 11 Mike Kaganski 2024-10-06 18:05:29 UTC
https://gerrit.libreoffice.org/c/core/+/174564
Comment 12 Commit Notification 2024-10-07 07:39:09 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/ff3791f67a6421d64f5f9d6a09feaead1a63ff92

tdf#163219: only create local With variable for function results

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Jean-Pierre Ledure 2024-10-07 08:23:53 UTC
(In reply to Mike Kaganski from comment #11)
> https://gerrit.libreoffice.org/c/core/+/174564

I prepared
https://gerrit.libreoffice.org/c/core/+/174560
but was prevented from pushing by Jenkins.

I will retain this chang.
I will abondon it if yours is validated.

Thx.
Comment 14 Mike Kaganski 2024-10-07 08:33:37 UTC
(In reply to Jean-Pierre Ledure from comment #13)
> I prepared
> https://gerrit.libreoffice.org/c/core/+/174560
> but was prevented from pushing by Jenkins.

Thank you; I resumed the CI.

> I will abondon it if yours is validated.

Please don't. I think it's cleaner with your patch, regardless of the fixes I made. Generally, I think that WITH is often overkill, when using the fully qualified Foo.Bar is no less readable than .Bar. Still, it's great that your framework helped so much already to catch problems that I introduced.
Comment 15 Commit Notification 2024-10-07 13:05:01 UTC
Jean-Pierre Ledure committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0b6afed3b85b6599ecbd7e5ac97b080d3ffbbfbf

ScriptForge Fix tdf#163219 With blocks

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 16 Commit Notification 2024-10-08 08:23:15 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/acd0556dc8d0ee48c4a0b338a093c9ece029a57c

tdf#163219: only create local With variable for function results

It will be available in 24.8.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 17 Commit Notification 2024-10-08 13:23:01 UTC
Jean-Pierre Ledure committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/c2aa474465eb8156b0ce384bc64ba6298d2b61be

ScriptForge Fix tdf#163219 With blocks

It will be available in 24.8.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 18 Commit Notification 2024-10-10 21:30:42 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4c17c2303d2475aa080bbc10a0c5d0e9f253d505

tdf#163219: sc_scriptforge_test: Add unittest

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 19 Xisco Faulí 2024-10-14 07:34:05 UTC
*** Bug 163408 has been marked as a duplicate of this bug. ***