opensmalltalk-vm icon indicating copy to clipboard operation
opensmalltalk-vm copied to clipboard

primitiveImageFormatVersion may be not correct

Open marceltaeumel opened this issue 2 years ago • 12 comments

The return value of primitiveImageFormatVersion is hard-coded and does not consider the value of multipleBytecodeSetsActive, which is indeed important when trying to open a particular image with a particular VM.

See:

  • Interpreter >> #imageFormatVersion
  • StackInterpreter >> #imageFormatVersion
  • ObjectMemory >> #imageFormatVersion
  • Spur32BitMemoryManager >> #imageFormatVersion
  • Spur64BitMemoryManager >> #imageFormatVersion

And also:

  • StackInterpreter >> #imageFormatVersionFromSnapshot:
  • StackInterpreter >> #imageFormatVersionForSnapshot

Note that this can be fixed on the image-side by checking primitiveMultipleBytecodeSetsActive. Yet, we have a discrepancy between the definition of "image format" at time of snapshotting and during run-time.

marceltaeumel avatar May 30 '22 09:05 marceltaeumel

It is a VM bug, sorry for overlooking this. Proposed fix in VMMaker inbox VMMaker.oscog-dtl.3185

dtlewis290 avatar May 30 '22 18:05 dtlewis290

Fix is in VMMaker (VMMaker.oscog-dtl.3185), still need to commit generated code and build VM.

dtlewis290 avatar Jun 01 '22 18:06 dtlewis290

@marceltaeumel the fix inVMMaker.oscog-dtl.3185 is trivial, but I need someone else (you or Eliot) to do the code generation this time. The reason is that my generated code has differences that I cannot account for (specifically one value in the primitiveMetadataTable array is generated as 0x100 but should be 0x200, and in several places there are differences in integer type declarations). I have not be able to track down the reason for the differences, so I cannot commit the generated code.

dtlewis290 avatar Jun 02 '22 20:06 dtlewis290

Wow. This is not over. Next issue is in imageSegmentVersion. I will try to fix this on the image side for now. But this is still a bug in the VM primitve 98 primitiveStoreImageSegment... :-(

marceltaeumel avatar Jun 07 '22 13:06 marceltaeumel

The biggest issue for an image-side discrimination is that the VMMaker-specific constant 512 ... MultipleBytecodeSetsBitmask is not part of the regular image code. Which is a good thing, I suppose. Still ...

marceltaeumel avatar Jun 07 '22 13:06 marceltaeumel

For my understanding - is the concern with imageSegmentVersion a problem for practical reasons (something does not work as expected)? It certainly makes sense that an image segment should have a format number that matches the image from which it was saved, but as a practical matter does anything bad happen if this is not the case?

dtlewis290 avatar Jun 07 '22 23:06 dtlewis290

In the extreme case, surely it could mean that the data was in a completely non-acceptable format?

On 2022-06-07, at 4:26 PM, David T Lewis @.***> wrote:

For my understanding - is the concern with imageSegmentVersion a problem for practical reasons (something does not work as expected)? It certainly makes sense that an image segment should have a format number that matches the image from which it was saved, but as a practical matter does anything bad happen if this is not the case?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

tim

tim Rowledge; @.***; http://www.rowledge.org/tim Useful random insult:- A prime candidate for natural deselection.

OpenSmalltalk-Bot avatar Jun 07 '22 23:06 OpenSmalltalk-Bot

I am trying to understand the real-world scenario in which this matters. I have an image running Sista bytecodes and my image format is 68533. I save an image segment to disk, and that image segment contains objects that contain compiled code that contain Sista bytecodes. The saved image segment records itself with format number 68021 (not 68533). Later on, someone loads that image segment using a VM that is a year or two old, so the VM does not know about 68533. But the VM probably does know how to run Sista bytecodes because it is only a year or two old. Everything still works, so as a practical matter what is the problem?

dtlewis290 avatar Jun 08 '22 00:06 dtlewis290

Regarding image side code and MultipleBytecodeSetsBitmask in VMMaker, on the image side you would use this (only if necessary, and hopefully it is not necessary):

(ImageFormat fromInteger: 68021) requiresMultipleBytecodeSupport ==> false (ImageFormat fromInteger: 68533) requiresMultipleBytecodeSupport ==> true

dtlewis290 avatar Jun 08 '22 00:06 dtlewis290

[...] is the concern with imageSegmentVersion a problem for practical reasons [...] I am trying to understand the real-world scenario in which this matters. [...]

Well, loads of tests fail or err at the moment. Maybe we should just fix the image-side load code for image segments to also accept 68021, even if the imageFormatForSnapshot is 68533.

marceltaeumel avatar Jun 08 '22 06:06 marceltaeumel

I committed a quickfix via System-mt.1355. Yet, this topic might need more discussion.

marceltaeumel avatar Jun 08 '22 07:06 marceltaeumel

My apologies, please disregard. Marcel, thank you for doing the code generation :-)

Dave

On Thu, Jun 02, 2022 at 01:21:29PM -0700, David T Lewis wrote:

@marceltaeumel the fix inVMMaker.oscog-dtl.3185 is trivial, but I need someone else (you or Eliot) to do the code generation this time. The reason is that my generated code has differences that I cannot account for (specifically one value in the primitiveMetadataTable array is generated as 0x100 but should be 0x200, and in several places there are differences in integer type declarations). I have not be able to track down the reason for the differences, so I cannot commit the generated code.

-- Reply to this email directly or view it on GitHub: https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/638#issuecomment-1145304546 You are receiving this because you are subscribed to this thread.

Message ID: @.***>

OpenSmalltalk-Bot avatar Oct 11 '22 07:10 OpenSmalltalk-Bot