eh-steve / goloader

Compile, load and run Go code at runtime.
Apache License 2.0
46 stars 4 forks source link

Bugfix gcdata revert fed0a9e #2

Closed eh-steve closed 1 year ago

eh-steve commented 1 year ago

Revert fed0a9e as it was simply masking an upstream bug in symRef resolution when reading an archive.

Not all symRefs will have their name included in an archive's refNames, especially if they're goobj.AuxGotypes which point to a type from another package, so we need to keep track of any unresolved symRefs and try to resolve them all after we've loaded all archive files.

A typical bug case was where a package declared a global sync.Map (or any global whose type is from another package). These globals would be GC roots without any gcmasks/gcprogs since the type information for the global was not resolved correctly.

This commit also adds a JIT test case which probes this behaviour, and panics due to GC memory corruption before this change