Skip to content

fix lua not load type in a safe manner - #1144

Open
wuke32767 wants to merge 1 commit into
EverestAPI:devfrom
wuke32767:fix-safe-type
Open

fix lua not load type in a safe manner#1144
wuke32767 wants to merge 1 commit into
EverestAPI:devfrom
wuke32767:fix-safe-type

Conversation

@wuke32767

Copy link
Copy Markdown
Contributor

i got a zip that works

quirk.zip (compile it yourself)

@maddie480-bot maddie480-bot added the 1: review needed This PR needs 2 approvals to be merged (bot-managed) label Jul 12, 2026
@DashingCat

Copy link
Copy Markdown
Contributor

The mod in the zip is:

  • quirkModule.cs
using System;

namespace Celeste.Mod.quirk;

public class quirkModule : EverestModule
{
    [MonoMod.Game]
    class YetAnother;
    public override void Load()
    {
    }

    public override void Unload()
    {
    }
}
  • Ruler.cs
using Mono.Cecil;
using System;

namespace MonoMod
{
    [MonoModCustomAttribute(nameof(MonoModRules.Start))]
    public class GameAttribute : Attribute;

    public class MonoModRules
    {
        public static void Start(TypeDefinition type, CustomAttribute __)
        {
            var m = type.Module;
            var scope = new AssemblyNameReference("can you get it", new(1, 0, 0, 0));
            var btype = m.ImportReference(new TypeReference("who cares", "missing name", null, scope));
            type.BaseType = btype;
        }
    }
}

When attempting to load the mod without the changes, when Everest starts, it crashes with the following exception:
System.IO.FileNotFoundException: Could not load file or assembly 'can you get it, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

It also logs the following line:
[Warn] [modasmctx] Failed to load assembly 'can you get it, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' for module 'quirk'

The exception does not show up when applying the changes, only leaving the warning.

If I understand correctly what is happening, the issue is that the non-public class YetAnother is getting cached by LuaLoader, which should not happen as the class is not public.

Did this behavior cause issue with existing or upcoming mods?

@wuke32767

Copy link
Copy Markdown
Contributor Author

the only real-world program may be ILHookDebugger 0.99.9, if it's real-world program

i think it's because GetNestedTypes is trying to load a type that can't be loaded

Comment on lines 169 to 173
// Non-public type instances can still be passed / returned.
/*
if (!type.IsPublic)
continue;
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue?: isn't this the same for nonpublic nested types? but on line 178 you have if (!type.IsNestedPublic) return null;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, i see
so i guess you're at least not introducing a new problem lol

realistically i don't think this is a big deal since nested private types aren't used that much and it should be easy to change later if it turns out to be an issue ^_^

@microlith57 microlith57 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

@maddie480-bot

Copy link
Copy Markdown
Member

The pull request was approved and entered the 3-day last-call window. Since no PR should be merged within 3 days of the next rolling release, the last-call window is extended further.
If no further reviews happen, it will end on Aug 23, 2026, 12:00 AM UTC, after which the pull request will be able to be merged.

@maddie480-bot maddie480-bot added 3: last call window This PR was approved, and is in the 5-day last-call window before getting merged (bot-managed) and removed 1: review needed This PR needs 2 approvals to be merged (bot-managed) labels Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3: last call window This PR was approved, and is in the 5-day last-call window before getting merged (bot-managed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants