| Summary: | "CallByName" does not work when the returned value is an array | ||
|---|---|---|---|
| Product: | LibreOffice | Reporter: | Jean-Pierre Ledure <jp> |
| Component: | BASIC | Assignee: | Not Assigned <libreoffice-bugs> |
| Status: | NEW --- | ||
| Severity: | normal | CC: | alain.romedenne, andreas.heinisch, arnaud.versini, aron.budea, himajin100000, jp, mikekaganski, rafael.palma.lima |
| Priority: | medium | ||
| Version: | 4.0.0.3 release | ||
| Hardware: | All | ||
| OS: | All | ||
| URL: | https://docs.microsoft.com/en-us/openspecs/microsoft_general_purpose_programming_languages/ms-vbal/b195f168-fb71-428d-b12d-1ab490ba64a4 | ||
| Whiteboard: | |||
| Crash report or crash signature: | Regression By: | ||
| Bug Depends on: | |||
| Bug Blocks: | 127592 | ||
| Attachments: | Test case | ||
|
Description
Jean-Pierre Ledure
2020-11-12 09:57:01 UTC
Created attachment 167231 [details]
Test case
To reproduce the error:
- open the attached file
- In the Basic IDE, run the TestCallByNameArray() Sub stored in Module1.
Confirmed in Version 4.0.0.3 (Build ID: 527dba6f6e0cfbbc71bd6e7b88a52699bb48799) The issue is only with return value, no problem for parameters Added Mike Kaganski to cc-list. Mike, if you ever can help solving this issue, this would improve the mechanism used by ScriptForge for Python calls handling, that is based on CallBtName(). Thanks anyway for your support. The problem happens in SbRtl_CallByName [1], in SbMethod::Call [2], when calling SbxValue::Put [3]. The latter one checks if rVal.eType & 0xF000 gives non-zero, and errors out in that case. When the assigned value is an array, rVal.eType has SbxDataType::SbxARRAY flag (0x2000) [4]. Returning arrays from functions works, so we need to check how the return is implemented, and use that instead of SbxValue::Put. Andreas: the one for you? ;) [1] https://opengrok.libreoffice.org/xref/core/basic/source/runtime/methods1.cxx?r=bc1ab88f&mo=2931&fi=96#205 [2] https://opengrok.libreoffice.org/xref/core/basic/source/classes/sbxmod.cxx?r=f4ff0ed5#2071 [3] https://opengrok.libreoffice.org/xref/core/basic/source/sbx/sbxvalue.cxx?r=565a5fde#392 [4] https://opengrok.libreoffice.org/xref/core/include/basic/sbxdef.hxx?r=de81c254&mo=3494&fi=80#80 I tried to tackle this bug several times :) maybe this time we can get over it. It actual fails in SbxValue::TheRealValue [1] because the return value is an object and not an array. I have to check the differences between returning an array directly and using call by name. [1] https://opengrok.libreoffice.org/xref/core/basic/source/sbx/sbxvalue.cxx?r=565a5fde#201 (In reply to Mike Kaganski from comment #6) Oh sorry, I need to stop answering after only code-reading, without debugging. I must say that for me, the problem manifests a bit different, not with "BASIC runtime error. Incorrect property value.", but with "BASIC runtime error. '9' Index out of defined range." Then, debugging that, the call stack at the moment of generating *that* error is > sblo.dll!SbxDimArray::Offset(SbxArray * pPar) Line 504 C++ > sblo.dll!SbxDimArray::Get(SbxArray * pPar) Line 532 C++ > sblo.dll!SbiRuntime::CheckArray(SbxVariable * pElem) Line 3965 C++ > sblo.dll!SbiRuntime::FindElement(SbxObject * pObj, unsigned long nOp1, unsigned long nOp2, ErrCode nNotFound, bool bLocal, bool bStatic) Line 3737 C++ > sblo.dll!SbiRuntime::StepRTL(unsigned long nOp1, unsigned long nOp2) Line 4132 C++ > sblo.dll!SbiRuntime::Step() Line 832 C++ > sblo.dll!`anonymous namespace'::RunInitGuard::run() Line 1015 C++ > sblo.dll!SbModule::Run(SbMethod * pMeth) Line 1178 C++ > sblo.dll!SbModule::Notify(SfxBroadcaster & rBC, const SfxHint & rHint) Line 776 C++ > svllo.dll!SfxBroadcaster::Broadcast(const SfxHint & rHint) Line 41 C++ > sblo.dll!SbMethod::Broadcast(SfxHintId nHintId) Line 2113 C++ > sblo.dll!SbxValue::Get(SbxValues & rRes) Line 289 C++ > basctllo.dll!basctl::RunMethod(const SbMethod * pMethod) Line 281 C++ > basctllo.dll!basctl::ModulWindow::BasicExecute() Line 367 C++ > basctllo.dll!basctl::ModulWindow::BasicRun() Line 387 C++ > basctllo.dll!basctl::ModulWindow::ExecuteCommand(SfxRequest & rReq) Line 908 C++ > basctllo.dll!basctl::Shell::ExecuteBasic(SfxRequest & rReq) Line 235 C++ > basctllo.dll!SfxStubbasctl_ShellExecuteBasic(SfxShell * pShell, SfxRequest & rReq) Line 153 C++ > ... and I am really confused with what is the logic of SbiRuntime::CheckArray [1] - it tries to get the element defined by parameter array in the returned array, which looks absolutely crazy to me. pElem points to "CallByName" method, pElemObj (and pDimArray) points to the returned array(1,2,3), and pPar points to the 5-element array of [ptr_to_CallByName_as_retval, ptr_to_Module2, "SomeMethod", 1, array(1,2,3)]. SbxDimArray::Offset takes the passed 5-element array as the array of indices in the dimensions (1 in pDimArray), and indeed, that fails. OTOH, maybe there's something missing like clearing of the parameters before returning from SbRtl_CallByName ... but IIUC, that should not happen there, needs debugging. Actually, I'm a bit lost. ATM, I can't spend much time on this, sorry. [1] https://opengrok.libreoffice.org/xref/core/basic/source/runtime/runtime.cxx?r=7c9d99a5#3952 (In reply to Mike Kaganski from comment #8) Ouch, I need some morning coffee. Sorry for spamming. The mentioned "BASIC runtime error. '9' Index out of defined range." is in VBASupport mode, not in Compatible mode, as described in comment 0. Sorry again. In basketball stars unblocked practice your aim. The more you practice, the better you'll become at shooting the ball. Souces: https://basketballstarsunblocked.io |