Lyricdev
GitHub

LYR-RT0023

a GcHandle that holds another class's object

panic · spec 13-abi

A GcHandle made again from C's pointer with GcHandle<T>.from was read, and the object its root holds is of another class than T, or the root holds none.

Explanation

GcHandle.from turns the pointer C kept back into a handle; the type it is read as is the program's word, in an unsafe block. Reading checks that word against the object: a handle of one class read as another's stops the program rather than hand out an object of the wrong layout.

Read the handle as the class it was pinned with — the pointer C hands back is the one asPtr() of that handle gave.

Example

$ ./out/debug/x86_64-linux-gnu/app
panic [LYR-RT0023]: a GcHandle of app.main.Counter read as a handle of app.main.Other