HashLink object equality appears to fail

I have a pretty complicated piece of code (a game engine) and at one point it appears that a check of:

var object:My_interface;
function do_function(arg_object:My_interface) {
    if(object==arg_object) {
       return;//this does not happen
    }
}

Does not behave as expected. The object is essentially the cmder that is constructed at world creation and is then assigned to every object in the world.

I have done a test of Reflect.field(object,“name”) where I generated a random name for the object and arg_object name is the same as object name. I did a stack trace and I do not construct the cmder more than once. This is the scope of my debugging so far.

Is an error of this type possible in HashLink? I am quite convinced that this is the case.

Is there a way to dump from haxe code some memory information of both these objects?

Hello,

HL VM should protect against such scenario. It is unclear why you use object == arg_object if object is assigned to every object in the world (check should always succeed?) How is it assigned?

Conditional statement object == arg_object compares two object instances (reference pointers). Which version of the HL are you using? I read somewhere new version using Immix GC have issues.

The check is to make sure that an object that may have been attached to a different simulation has been cleanly removed from the previous simulation. I see about immix. I think there is failure in what is happening in the VM. I am using hashlink 1.12 win 64.

I have created checks on every assignment of this cmd object and compared it to a static variable that has been assigned at cmder construction. I do not anywhere assign a cmder to any object that is different from the static reference. But in this instance, if(osm==Utils.debugo) returns false.

The VM appears to have garbled the identity of the previously assigned osm.

public function osm_dock_t(losm:Osmi<Od>):Void {
		T.d("osm_dock_t "+sb(),"dd");
		if(osm==losm) {
			T.t("osm==losm");
			return;
		}
		var losm2:Dynamic=losm;
		var osm2:Dynamic=osm;
		if(osm2==losm2) {
			T.t("osm2==losm2");
		}
		if(osm==Utils.debugo) {
			T.t("osm==Utils.debugo");
		}
		if(losm==Utils.debugo) {
			T.t("losm==Utils.debugo");
		}
		T.t("osm:"+osm);
		T.t("losm:"+losm);
		T.t("Utils.debugo:"+Utils.debugo);
		if(osm!=null) {
			trace("osm.name:"+Reflect.field(osm,"name"));
			if(losm!=null) {
				trace("losm.name:"+Reflect.field(losm,"name"));
			}
			throw "osm is not null, objects should be cleanly removed from an osm before adding to a different osm";
		}

Utils is here a black-box: we don’t see what are methods doing there. Also osm is unclear: member variable initialized to Utils.debugo value at some point, or?

public var osm:Osmi; is a member of every object.

It is the constructed cmder. Osm stands for objects manager.

As a debug implementation, I assigned it to Utils.debugo at construction.

Anyway, I am fairly certain hashlink VM is doing something suspicious.

Try to downgrade HL up to the point you get things working correctly, or you reach missing feature either by HL or Haxe as language. Have you tried to build your project from the generated C sources, I don’t know how far HL progressed here?

Can you build your project using HXCPP or it is HL specific (libraries)?

Yeah, I’ll give a try. Thanks