Bug 159412 - Passing Integer-sized Long argument via script.invoke as 0
Summary: Passing Integer-sized Long argument via script.invoke as 0
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.2.0.4 release
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:24.8.0 target:24.2.1 target:7.6.5
Keywords: bibisectNotNeeded, regression
Depends on:
Blocks:
 
Reported: 2024-01-28 11:28 UTC by Patrick Traill
Modified: 2024-01-30 18:21 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 Patrick Traill 2024-01-28 11:28:18 UTC
First reported at https://ask.libreoffice.org/t/is-this-a-bug-in-script-invoke-passing-integer-sized-long-argument-as-0/101256/4 .
There Mike Kaganski said he had tested it in 7.2, where the error occurred, and 7.1, which worked correctly.

I have left Severity / Hardware / OS at their default values, as they sound plausible.

---
When I try to pass a `Long` via `script.invoke` it is passed as 0 if the receiving argument is declared as `Long` but the value fits in an Integer. If the same value is passed to `Any` or `Integer`, the correct value is received. Values that need a `Long` are also correctly received.

Whenever `Script_invoke_Bug_invokee_3` in the code below is called (because the value fits in an `Integer`), it reports `y_A` as 0! In all other cases the correct value is reported.

I am running this version:
Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 8; OS: Linux 5.3; UI render: default; VCL: kf5 (cairo+xcb)
Locale: en-GB (en_GB.UTF-8); UI: en-GB
Calc: threaded

```
Const Int_Max = 2 ^ 15 - 1		' Seems to be right
Const Int_Min = - 2 ^ 15		' Seems to be right

Sub Script_invoke_Bug
	Dim	z_Integer					as	Integer	:	z_Integer	= 1024
	Script_invoke_Bug_invoker (z_Integer)

	Dim	z_Long_1024					as	Integer	:	z_Long_1024	= 1024
	Script_invoke_Bug_invoker (z_Long_1024)

	Dim	z_Long						as	Long	:	z_Long		= 1048576
	Script_invoke_Bug_invoker (z_Long)

	Script_invoke_Bug_invoker (1048575)

	Script_invoke_Bug_invoker (Int_Max)

	Script_invoke_Bug_invoker (Int_Max + 1)

	Script_invoke_Bug_invoker (Int_Min)

	Script_invoke_Bug_invoker (Int_Min - 1)
End Sub

Sub Script_invoke_Bug_invoker (y as Any)
	Dim	z_Count						as Integer	:	z_Count		= IIf (y < Int_Min or Int_Max < y, 2, 3)
	Dim	z_Invokee					as	String	:	z_Invokee	= "Script_invoke_Bug_invokee_" + z_Count
	Dim	z_URI						as	String	:	z_URI		= "vnd.sun.star.script:Standard.Pjt_Scratch." + z_Invokee + "?language=Basic&location=application"
	Dim z_Script					as	Object	:	z_Script	= ThisComponent.scriptProvider.getScript (z_URI)

	Dim	z_Parameters	(0 to 2)	as	Any
	z_Parameters (0)	= y
	z_Parameters (1)	= y
	z_Parameters (2)	= y

	Dim	z_Out_Parameter_Indices	()	as	Integer
	Dim	z_Out_Parameters		()	as	Any

	z_Script.invoke (z_Parameters, z_Out_Parameter_Indices, z_Out_Parameters)
End Sub

Sub Script_invoke_Bug_invokee_3 (y_A as Long, y_B as Integer, y_C as Any)
	MsgBox ("A = " + y_A + ",  B = " + y_B + ",  C = " + y_C)
End Sub

Sub Script_invoke_Bug_invokee_2 (y_A as Long, y_C as Any)
	MsgBox ("A = " + y_A + ",  C = " + y_C)
End Sub
```
Comment 1 Patrick Traill 2024-01-28 11:29:38 UTC
Noted by Mike Kaganski as possibly related: https://bugs.documentfoundation.org/show_bug.cgi?id=133889 and https://bugs.documentfoundation.org/show_bug.cgi?id=133887 .
Comment 2 Mike Kaganski 2024-01-28 12:38:10 UTC
Confirmed.
Comment 3 Mike Kaganski 2024-01-28 17:58:00 UTC
https://gerrit.libreoffice.org/c/core/+/162664
Comment 4 Commit Notification 2024-01-29 02:34:59 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4541614e5f88604b4b1e17b0223d11c2e330d451

tdf#159412: make sure to keep the value while changing the type

It will be available in 24.8.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 5 Patrick Traill 2024-01-29 14:24:40 UTC
I tried to test this, but maybe my Open Suse Linux 15.3 is too old, or at least Qt5?
(I really must update Open Suse to 15.4!)

I am told there is an undefined symbol: _ZNK7QWidget6screenEv

libQt5* are on 5.12.7-<various>, e.g. -2.35, -1.53, 4-17.1, with nothing higher available in my repositories, i.e. even with repository change allowed.

I could install the daily build without errors, but when I tried to run it I got this:

pjtraill@PatrickLaptopLinux:~/Downloads/Use/SystemManagement/Software/LibreOffice/DailyBuilds/LibreOfficeDev_24.8.0.0.alpha0_Linux_x86-64_rpm/bin/opt/libreofficedev24.8/program> ./soffice
/home/pjtraill/Downloads/Use/System Management/Software/Libre Office/DailyBuilds/LibreOfficeDev_24.8.0.0.alpha0_Linux_x86-64_rpm/bin/opt/libreofficedev24.8/program/soffice.bin: symbol lookup error: /home/pjtraill/Downloads/Use/System Management/Software/Libre Office/DailyBuilds/LibreOfficeDev_24.8.0.0.alpha0_Linux_x86-64_rpm/bin/opt/libreofficedev24.8/program/libvclplug_qt5lo.so: undefined symbol: _ZNK7QWidget6screenEv, version Qt_5
Comment 6 Commit Notification 2024-01-30 11:38:38 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-24-2":

https://git.libreoffice.org/core/commit/411a567b7eb0693a98143f9cdf74ac3b5f8ef56e

tdf#159412: make sure to keep the value while changing the type

It will be available in 24.2.1.

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 7 Commit Notification 2024-01-30 18:21:36 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-7-6":

https://git.libreoffice.org/core/commit/5db313902110c95c440bb0e96f46acc97092d7ca

tdf#159412: make sure to keep the value while changing the type

It will be available in 7.6.5.

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.