Skip to content

Parameter capture fails in Minecraft Classic/Indev/Infdev #180

@SpaceWalkerRS

Description

@SpaceWalkerRS

The Proguard settings used for these versions include a local variable optimization that drops locals to lower indices in the stack frame. It even re-uses indices normally reserved for the method parameters. As a result, (some) parameters are no longer accessible from everywhere in the method.

As an example, in Minecraft Infdev 0.31.20100629 there's a method MobEntity.die(Entity)void (Feather mappings). At the start of the method, there are just two locals in the stack frame:

  • 0: MobEntity (the this variable)
  • 1: Entity (the method parameter)

Early on in the method, a new int variable is created, after which the following locals are in the stack frame:

  • 0: MobEntity (the this variable)
  • 1: int (the new variable)

The method parameter has completely disappeared, and is no longer accessible from this point on. This causes crashes when injectors target any instruction after this point, and try to access the method parameter. Mixin assumes the parameter is available at index 1, and attempts to pass the int variable where an Entity variable is expected, leading to a VerifyError.

I am not sure if it is within scope for Mixin to fix this, but I thought it would be good to have it documented regardless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions