Bug 166673 - BASIC: Calling Space(-1) succeeds in release version (even in VBA support mode), crashes in debug version
Summary: BASIC: Calling Space(-1) succeeds in release version (even in VBA support mod...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Belu Antonie-Gabriel
URL:
Whiteboard: target:26.8.0 target:26.2.4
Keywords: difficultyBeginner, easyHack, skillCpp
Depends on:
Blocks: Macro-VBA Crash Dev-related
  Show dependency treegraph
 
Reported: 2025-05-21 11:32 UTC by Mike Kaganski
Modified: 2026-05-11 17:58 UTC (History)
3 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 Mike Kaganski 2025-05-21 11:32:48 UTC
This Basic code succeeds in release version:

 Space(-1)

In release version, this aborts because of failed assertion.

1. In VBA, this code gives Invalid Procedure Call run-time error (5).
We need to do the same in VBASupport mode.

2. We can't do that in non-VBA mode, because there is existing code relying on current behavior. We need to sanitize the passed value instead, so that it reaches the internals, where the "non-negative" preconditions must be met, in a valid state.

Code pointer: SbRtl_Space in basic/source/runtime/methods.cxx.
The patch must contain unit tests both for non-VBA, and VBA support cases.
Comment 1 Mike Kaganski 2025-05-21 12:09:44 UTC
(In reply to Mike Kaganski from comment #0)
> In release version, this aborts because of failed assertion.

A thinko: it was intended to be "In *debug* version, this aborts because of failed assertion"
Comment 2 Commit Notification 2026-04-22 15:46:52 UTC
bl4ze4447 committed a patch related to this issue.
It has been pushed to "master":

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

tdf#166673 Fix Space(-1) behaviour

It will be available in 26.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 3 Commit Notification 2026-04-23 07:12:20 UTC
bl4ze4447 committed a patch related to this issue.
It has been pushed to "libreoffice-26-2":

https://git.libreoffice.org/core/commit/2bbd8be0d2792c9655868d8958cd73057c489cec

tdf#166673 Fix Space(-1) behaviour

It will be available in 26.2.4.

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.