Written by

Question D Sun · Mar 1, 2018

GetSwizzled error in cache

 I  keep seeing  <INVALID OREF>zMypropertyGetSwizzled+3^myClass.2  in the error log.  In my case,  Myproperty   is a property of  myClass. And Myproperty points to the the object of other class in the system. This error happens to 2 properties in the same class, and they are both object properties. This error pops up occasionally, and make the debugging harder.

Anyone knows what the issues are?

TIA

Comments

Eduard Lebedyuk · Mar 1, 2018

Please post this line of code (Open myClass -> See other code -> zMypropertyGetSwizzled routine, third line) :

zMypropertyGetSwizzled+3^myClass.2

0
D Sun  Mar 1, 2018 to Eduard Lebedyuk

class myClass extends (%persisten)

{

Property Someproperty As %String;

...

Property Myproperty1 As   OtherClass1;

Property Myproperty2 As  OtherClass2;

... some more other property total 215 properties in this class

}

class OtherClass1 extends (%persisten)

{

Property OtherClass1Property As %String;

}

ClassMethod myfuct( id) As %String

{

set ref=##class(myClass).%OpenId(id)

set str="my return: "_ref.Myproperty1.OtherClass1Property

quit str

}

Above is a  similar situation and codes. When myfuct is called, sometimes it throws a  <INVALID OREF>zMypropertyGetSwizzled+3^myClass.2

myClass is  a very busy table.

0
Eduard Lebedyuk  Mar 1, 2018 to D Sun

You need to press "View other code" button (or Ctrl+Shift+V) and post zMypropertyGetSwizzled routine.

0
D Sun  Mar 1, 2018 to Eduard Lebedyuk
zMypropertyGetSwizzled(%this) public {If $zobjval(,/*i%Myproperty*/163,0,3,163)="" Quit ""Set oref=##class( OtherClass ).%Open($select($zobjval(,/*i%Myproperty*/163,0,3,163)="":"",1:$listbuild($zobjval(,/*i%Myproperty*/163,0,3,163)_""))) If oref="" Quit ""Set modstate=$zobjval(,0) Set $zobjval(,/*r%Myproperty*/164,0,3,164)=oref Set $zobjval(,0)=$e(modstate,1,$l(modstate)\2)_$e($zobjval(,0),$l(modstate)\2+1,*)Quit oref }
0
D Sun  Mar 1, 2018 to D Sun

In the above sample, Myproperty can be Myproperty1 or Myproperty2. Any thoughts?

0
Robert Cemper  Mar 1, 2018 to D Sun

you do 

set ref=##class(myClass).%OpenId(id)

but you don't check if you really got an object.  the id might be invalid
continue with 

if '$isobject(ref) quit ""

0
D Sun  Mar 1, 2018 to Robert Cemper

It is valid in the db, just not getting it.  Don't know why. I am new to this.

0
Robert Cemper  Mar 1, 2018 to D Sun

you need an oref in ref 
and also in Myproperty1, ... 
So you have to check both . see answer

0
D Sun  Mar 1, 2018 to Robert Cemper

Thanks! very Interesting find. I will try that tomorrow. GetSwizzled  means getting object from memory or what? I don't quite understand this.

0
Eduard Lebedyuk  Mar 1, 2018 to Robert Cemper

It shouldn't compile at all.

OP please post

w $zv
0
Robert Cemper · Mar 1, 2018

the code causing the problem in MyClass.2.int looks most likely like this:

Set oid=$select(i%Myproperty="":"",1:$listbuild(i%Myproperty_""))

you are inside an ObjectMethod   and miss the actual Object  reference.
This happens when you try to access a property inside a Classmethod.
 classic mistake:

ClassMethod MyMethod(1,2,3) as %Status {
 set x=..Myproperty
}

correct use: 

ClassMethod MyMethod(oref,1,2,3) as %Status {
 set x=oref.Myproperty
}
0
D Sun  Mar 1, 2018 to Eduard Lebedyuk

Those codes are not real codes, just give an idea what is happening ( I can't post real codes). The real codes works fine until couple days ago I start seeing those errors.

the $zv returns:

Cache for UNIX (IBM AIX for System P5-64) 2010.2.4 (Build 802_1_17238) Tue Apr 4 2017 19:48:24 EDT

0
Robert Cemper · Mar 1, 2018
ClassMethod myfuct( id) As %String
{
  set ref=##class(myClass).%OpenId(id)
  If '$isobject(ref) quit "no object 1, no return"
  if '$isrobject(ref.
Myproperty1) quit "no object 2, no return"
  set str="my return: "_ref.Myproperty1.OtherClass1Property
  quit str
}
0