Summary: | Unexpected result when executing Redim statement on an array of structures | ||
---|---|---|---|
Product: | LibreOffice | Reporter: | Vladimir Sokolinskiy <sokol> |
Component: | BASIC | Assignee: | Andreas Heinisch <andreas.heinisch> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | buzea.bogdan, himajin100000, oliver.brinzing |
Priority: | medium | ||
Version: | Inherited From OOo | ||
Hardware: | All | ||
OS: | All | ||
See Also: | https://bugs.documentfoundation.org/show_bug.cgi?id=124008 | ||
Whiteboard: | target:7.2.0 | ||
Crash report or crash signature: | Regression By: | ||
Bug Depends on: | |||
Bug Blocks: | 127592 |
Description
Vladimir Sokolinskiy
2020-09-14 15:55:59 UTC
already reproducible with: LibreOffice 3.3.0 OOO330m19 (Build:6) tag libreoffice-3.3.0.4 Some observations: In https://opengrok.libreoffice.org/xref/core/basic/source/runtime/runtime.cxx?r=d84deb95#3870 the information about the array dimension is lost and then it cannot be redimensioned in https://opengrok.libreoffice.org/xref/core/basic/source/runtime/runtime.cxx?r=d84deb95#2151. After I re-added the parameters, the array will get the new dimensions, and the new objects for the redimensioned array will be created in https://opengrok.libreoffice.org/xref/core/basic/source/runtime/runtime.cxx?r=d84deb95#4440. However, the old array somehow survives in the expression stack and will be read for the UBound function, leading to the error. Some additional findings: The script does indeed work with ReDim Preserve, where the only additional command generated by the compiler is StepREDIMP_ERASE and DCREATE_REDIMP_ instead of DCREATE_. Atm, SbiRuntime::StepDCREATE and SbiRuntime::StepDCREATE_REDIMP are the same. At runtime, the function SbiRuntime::StepREDIMP_ERASE copies a reference to the array and reuses it in SbiRuntime::CheckArray, where it prevents the retrieval of a new array element using the old reference. Without Preserve, the first element of the array will be passed as an argument, leading to missing dimensions in SbiRuntime::DimImpl. However, I don't know how to retrieve the correct variable SbiRuntime::CheckArray without breaking additional functionalities. Andreas Heinisch committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/0426748927919dbfd4cf5c0bb904e21a90d6c9d7 tdf#136755, tdf#124008 - delete the variable beforehand REDIM It will be available in 7.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. |