Single-role references accept a locator that belongs to another TBoldSystem, while the list side (TBoldObjectList.CheckAdd/CheckReplace) rejects it. Found during a full-history code review (finding M2). Not a regression — the guard has been missing on the single-reference side since the original BoldSoft code.
Symptom
Assigning a single-role association across two live TBoldSystem instances (e.g. A1.next := A2 where A1 and A2 live in different systems) is silently accepted. The stored locator's ID belongs to the other system's database, so persisting the link writes a foreign ID — a dangling-link corruption once the two databases diverge.
Root cause
TBoldObjectList.CheckAdd/CheckReplace in Source/ObjectSpace/BORepresentation/BoldSystem.pas guard multilinks with OwnedByObject and (BoldSystem <> NewLocator.BoldSystem).
- The single-reference counterpart
TBoldObjectReference.CanSetLocator only calls VerifyClass — it never compares systems, so cross-system locators pass validation and are stored.
Fix
- TBoldObjectReference.CanSetLocator: after
VerifyClass, reject when Assigned(NewLocator) and OwnedByObject and (BoldSystem <> NewLocator.BoldSystem), setting a failure reason so SetLocator's existing BoldRaiseLastFailure turns it into a raised exception — same mechanism as the list side.
- BoldCoreConsts: new
sCannotLinkAcrossSystems message constant.
- Test:
TestSetLocatorRejectsCrossSystemObject in UnitTest/Code/ObjectSpace/Test.BoldSystem.pas — two live systems sharing one SystemTypeInfoHandle; verifies the assignment raises and nothing is stored (red before the fix, green after).
Files changed
Source/ObjectSpace/BORepresentation/BoldSystem.pas
Source/ObjectSpace/Core/BoldCoreConsts.pas
UnitTest/Code/ObjectSpace/Test.BoldSystem.pas
Testing
Single-role references accept a locator that belongs to another
TBoldSystem, while the list side (TBoldObjectList.CheckAdd/CheckReplace) rejects it. Found during a full-history code review (finding M2). Not a regression — the guard has been missing on the single-reference side since the original BoldSoft code.Symptom
Assigning a single-role association across two live
TBoldSysteminstances (e.g.A1.next := A2whereA1andA2live in different systems) is silently accepted. The stored locator's ID belongs to the other system's database, so persisting the link writes a foreign ID — a dangling-link corruption once the two databases diverge.Root cause
TBoldObjectList.CheckAdd/CheckReplaceinSource/ObjectSpace/BORepresentation/BoldSystem.pasguard multilinks withOwnedByObject and (BoldSystem <> NewLocator.BoldSystem).TBoldObjectReference.CanSetLocatoronly callsVerifyClass— it never compares systems, so cross-system locators pass validation and are stored.Fix
VerifyClass, reject whenAssigned(NewLocator) and OwnedByObject and (BoldSystem <> NewLocator.BoldSystem), setting a failure reason soSetLocator's existingBoldRaiseLastFailureturns it into a raised exception — same mechanism as the list side.sCannotLinkAcrossSystemsmessage constant.TestSetLocatorRejectsCrossSystemObjectinUnitTest/Code/ObjectSpace/Test.BoldSystem.pas— two live systems sharing oneSystemTypeInfoHandle; verifies the assignment raises and nothing is stored (red before the fix, green after).Files changed
Source/ObjectSpace/BORepresentation/BoldSystem.pasSource/ObjectSpace/Core/BoldCoreConsts.pasUnitTest/Code/ObjectSpace/Test.BoldSystem.pasTesting