Bug 150491 - Infinite recursion in a VBA macro that works without errors in Excel
Summary: Infinite recursion in a VBA macro that works without errors in Excel
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.0 all versions
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
 
Reported: 2022-08-19 07:24 UTC by Mike Kaganski
Modified: 2024-08-19 10:31 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
An XLSM with a VBA macro showing infinite recursion in LibreOffice Basic (12.98 KB, application/vnd.ms-excel.sheet.macroEnabled.12)
2022-08-19 07:24 UTC, Mike Kaganski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2022-08-19 07:24:19 UTC
Created attachment 181876 [details]
An XLSM with a VBA macro showing infinite recursion in LibreOffice Basic

Running 'main' macro from the attachment produces this error:

> BASIC runtime error.
> '28'
> Not enough stack memory.

It runs OK in Excel, showing a message box with "1".

The macro code there is this:

Option VBASupport 1
Function NotRecursive()
  Set NotRecursive = New Collection
  NotRecursive.Add "Foo"
End Function

Sub main()
  Dim c
  Set c = NotRecursive
  MsgBox c.Count
End Sub

The infinite recursion happens on 'NotRecursive.Add "Foo"', where LibreOffice Basic tries to call the function again.

Possibly this should only be fixed in VBASupport mode.
Comment 1 Roman Kuznetsov 2022-08-19 07:37:09 UTC
Confirm in

Version: 7.5.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: bfca51d9035000e518e4938ceb145cb92cc17b1f
CPU threads: 8; OS: Windows 10.0 Build 19043; UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: ru-RU
Calc: threaded
Comment 2 Xisco Faulí 2022-08-19 09:47:52 UTC
Also reproduced in

Version: 6.4.0.0.alpha1+
Build ID: 9bc848cf0d301aa57eabcffa101a1cf87bad6470
CPU threads: 8; OS: Linux 5.10; UI render: default; VCL: gtk3; 
Locale: es-ES (es_ES.UTF-8); UI-Language: en-US
Calc: threaded
Comment 3 QA Administrators 2024-08-19 03:14:59 UTC Comment hidden (obsolete)
Comment 4 Werner Tietz 2024-08-19 06:26:09 UTC Comment hidden (off-topic)
Comment 5 Mike Kaganski 2024-08-19 06:37:55 UTC
(In reply to Werner Tietz from comment #4)

Bugzilla issues are not requests to find workarounds (that exist, but they are on-topic on sites like ask.libreoffice.org). Bugs like this are to make sure that the program behaves as required (in this case, as needed to ensure that existing VBA macros work in VBA support mode).
Comment 6 Werner Tietz 2024-08-19 09:01:09 UTC
(In reply to Mike Kaganski from comment #5)
> (In reply to Werner Tietz from comment #4)
> 
> Bugzilla issues are not requests to find workarounds (that exist, but they
> are on-topic on sites like ask.libreoffice.org). Bugs like this are to make
> sure that the program behaves as required (in this case, as needed to ensure
> that existing VBA macros work in VBA support mode).

maybe but IHMO:
vba support yes! ... but trying to support bad ambiguous code, NO!
Comment 7 Mike Kaganski 2024-08-19 09:13:02 UTC
(In reply to Werner Tietz from comment #6)

We support code not because it is good or bad, but because it should work. LibreOffice is not a tool to check code quality, and when something works in Excel / Word, users expect it to work in LibreOffice.

Discussion of quality of code is again off-topic here. Please avoid.