Bug 150491

Summary: Infinite recursion in a VBA macro that works without errors in Excel
Product: LibreOffice Reporter: Mike Kaganski <mikekaganski>
Component: BASICAssignee: Not Assigned <libreoffice-bugs>
Status: NEW ---    
Severity: normal CC: 79045_79045, andreas.heinisch, xiscofauli
Priority: medium    
Version: 7.0 all versions   
Hardware: All   
OS: All   
Whiteboard:
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 108908    
Attachments: An XLSM with a VBA macro showing infinite recursion in LibreOffice Basic

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