Apache OpenOffice (AOO) Bugzilla – Issue 70616
Basic finds inexistent runtime error before running the code
Last modified: 2017-05-20 10:44:09 UTC
Problem found on OOo 2.0.4 and 1.1.5. The following example of Basic subroutine cannot be called: Sub tata2(a As Variant, d As Long) if d=0 then print a.xx else print "OK" end if End Sub When you call this routine with a code like: tata2(5,1) you get this message: Basic runtime error. Object variable not set. And Basic shows in the IDE the first line of the sub: Sub tata2(a As Variant, d As Long) All this is absolute non-sense: Basic is complaining in fact about handling variable "a" as an object in an instruction which is not executed. And it does not show the incriminated instruction! In a real programming situation it can be very difficult to find the origin of the problem in a big and complex sub. Next attachment is a Basic example. A workaround is to use an intermediate variable to fool the interpreter.
Created attachment 39884 [details] Document containing a Basic proof of the bug
Andreas, please take care of this as well ... ;-)
It's indeed confusing, that in this case the wrong line is marked in the IDE. But I doubt that this will "probably affect a noticeable number of users" like specified as condition for P3, -> P4, STARTED, 2.x
set target to 3.x according to http://wiki.services.openoffice.org/wiki/Target_3x
-> OOo Later
Created attachment 82762 [details] Two examples of incorrect runtime error This attachment is an updated version of the original one. Macro Main1 in Module1 is the original case : error message before execution of a routine. Macro Main2 in Module2 is a simpler case : error message when re-using a Variant.
Trying to have a code compatible with Apache OpenOffice and LibreOffice, I stumbled again on this horrible bug. A Variant should always be re-usable into any type. The second example of the attachment shows that if, for some reason, you use a variable of type Variant that sometimes contain an object and sometimes contain a simple type, Basic will throw a runtime error. Furthermore, in this example an instruction that is NOT executed will trigger the error at another instruction.
Partial stack trace: #0 SbxBase::SetError (e=35180627536) at sbxbase.cxx:130 #1 0x0000000807c36515 in SbxValue::Get (this=0x830edc650, rRes=@0x7fffffffb678) at sbxvalue.cxx:578 #2 0x0000000807c355ed in SbxValue::operator= (this=0x8309fb180, r=@0x830edc650) at sbxvalue.cxx:338 #3 0x0000000807c3d367 in SbxVariable::operator= (this=0x8309fb180, r=@0x830edc650) at sbxvar.cxx:325 #4 0x0000000807be81d0 in SbiRuntime::SetParameters (this=0x81ff2b1a0, pParams=0x830f6ae00) at runtime.cxx:665 #5 0x0000000807be7b03 in SbiRuntime (this=0x81ff2b1a0, pm=0x827f05e48, pe=0x830912f00, nStart=56) at runtime.cxx:576 #6 0x0000000807b0d0e6 in SbModule::Run (this=0x827f05e48, pMeth=0x830912f00) at sbxmod.cxx:1143 #7 0x0000000807b0c6c5 in SbModule::Notify (this=0x827f05e48, rBC=@0x828ec9720, rHint=@0x7fffffffbef0) at sbxmod.cxx:797 #8 0x0000000807b0db77 in non-virtual thunk to SbModule::Notify(SfxBroadcaster&, SfxHint const&) (this=0x827f05ec8, rBC=@0x828ec9720, rHint=@0x7fffffffbef0) at sbxmod.cxx:817 #9 0x000000080393a337 in SfxBroadcaster::Broadcast () from /AOO/main/instsetoo_native/unxfbsdx/Apache_OpenOffice/installed/install/en-US/openoffice4/program/libsvl.so #10 0x0000000807b13945 in SbMethod::Broadcast (this=0x830fdd9b0, nHintId=65536) at sbxmod.cxx:2122 #11 0x0000000807c3523e in SbxValue (this=0x81ff06e60, vtt=0x807efe850, r=@0x830fdd9b0) at sbxvalue.cxx:273 #12 0x0000000807c3c19f in SbxVariable (this=0x81ff06e60, vtt=0x807efe848, r=@0x830fdd9b0) at sbxvar.cxx:91 #13 0x0000000807c024fe in SbxMethod (this=0x81ff06e60, r=@0x830fdd9b0) at sbxmeth.hxx:43 #14 0x0000000807bfcbf8 in SbiRuntime::FindElement (this=0x81feeecd0, pObj=0x827f05e48, nOp1=32770, nOp2=0, nNotFound=87560, bLocal=1 '\001', bStatic=0 '\0') at step2.cxx:254 #15 0x0000000807bff309 in SbiRuntime::StepFIND_Impl (this=0x81feeecd0, pObj=0x827f05e48, nOp1=32770, nOp2=0, nNotFound=87560, bLocal=1 '\001', bStatic=0 '\0') at step2.cxx:644 #16 0x0000000807bff37d in SbiRuntime::StepFIND (this=0x81feeecd0, nOp1=32770, nOp2=0) at step2.cxx:650 #17 0x0000000807be8ced in SbiRuntime::Step (this=0x81feeecd0) at runtime.cxx:748 #18 0x0000000807b0d203 in SbModule::Run (this=0x827f05e48, pMeth=0x827edc9c0) at sbxmod.cxx:1157 #19 0x0000000807b0c6c5 in SbModule::Notify (this=0x827f05e48, rBC=@0x830962220, rHint=@0x7fffffffca40) at sbxmod.cxx:797 #20 0x0000000807b0db77 in non-virtual thunk to SbModule::Notify(SfxBroadcaster&, SfxHint const&) (this=0x827f05ec8, rBC=@0x830962220, rHint=@0x7fffffffca40) at sbxmod.cxx:817 #21 0x000000080393a337 in SfxBroadcaster::Broadcast () from /AOO/main/instsetoo_native/unxfbsdx/Apache_OpenOffice/installed/install/en-US/openoffice4/program/libsvl.so #22 0x0000000807b13945 in SbMethod::Broadcast (this=0x8309122c0, nHintId=65536) at sbxmod.cxx:2122 #23 0x0000000807c361ed in SbxValue::Get (this=0x8309122c0, rRes=@0x7fffffffcb48) at sbxvalue.cxx:530 #24 0x00000008286e4883 in BasicIDE::RunMethod (pMethod=0x8309122c0) at basobj3.cxx:328 #25 0x00000008286bf71d in ModulWindow::BasicExecute (this=0x80af15220) at baside2.cxx:381 #26 0x00000008286bf9b4 in ModulWindow::BasicRun (this=0x80af15220) at baside2.cxx:414 #27 0x00000008286c4a05 in ModulWindow::ExecuteCommand (this=0x80af15220, rReq=@0x82902d830) at baside2.cxx:1034 #28 0x00000008286bb8e3 in BasicIDEShell::ExecuteBasic (this=0x825dfc438, rReq=@0x82902d830) at basides2.cxx:342 SbxValue::Get(), at sbxvalue.cxx:578: case SbxOBJECT: if( p->aData.eType == SbxOBJECT ) rRes.pObj = p->aData.pObj; else { /* 578: */ SetError( SbxERR_NO_OBJECT ); rRes.pObj = NULL; } break;
Reset the assignee to the default "issues@openoffice.apache.org".