Skip to content

fix(core): correct constructor mirror backup target and reset methodN… - #5

Open
nanhang-950 wants to merge 1 commit into
AlbatrossHook:mainfrom
nanhang-950:fix/constructor-mirror-backup-target-methodnames-reset
Open

fix(core): correct constructor mirror backup target and reset methodN…#5
nanhang-950 wants to merge 1 commit into
AlbatrossHook:mainfrom
nanhang-950:fix/constructor-mirror-backup-target-methodnames-reset

Conversation

@nanhang-950

Copy link
Copy Markdown

…ames per iteration

Bug 1 — Constructor "mirror backup" passed the wrong target member: In the HOOK_CONSTRUCTOR / BACKUP_CONSTRUCTOR branches (both hook and unhook paths) putMirrorBackup(backupRecords, targetMethod, ...) was called with targetMethod, which is always null in the constructor branch (it should be targetConstructor). This caused BackupRecord.target to be null, propagating into backup(null) / backupNative(null) and, on slot-populated classes, could silently fail or crash the ART runtime. Non-constructor method branches already passed targetMethod correctly and are unchanged.

Bug 2 — methodNames array reused across iterations retained stale data: String[] methodNames = new String[2]; was declared outside the loop. Each iteration only overwrote some slots (depending on whether the hook/backup member was null), so stale values from a previous target leaked into slotMap.containsKey matching, causing spurious slot matches for prior targets. Move the declaration inside the loop so every iteration gets a fresh array.

…ames per iteration

Bug 1 — Constructor "mirror backup" passed the wrong target member:
In the HOOK_CONSTRUCTOR / BACKUP_CONSTRUCTOR branches (both hook and unhook
paths) putMirrorBackup(backupRecords, targetMethod, ...) was called with
targetMethod, which is always null in the constructor branch (it should be
targetConstructor). This caused BackupRecord.target to be null, propagating
into backup(null) / backupNative(null) and, on slot-populated classes, could
silently fail or crash the ART runtime. Non-constructor method branches
already passed targetMethod correctly and are unchanged.

Bug 2 — methodNames array reused across iterations retained stale data:
String[] methodNames = new String[2]; was declared outside the loop. Each
iteration only overwrote some slots (depending on whether the hook/backup
member was null), so stale values from a previous target leaked into
slotMap.containsKey matching, causing spurious slot matches for prior targets.
Move the declaration inside the loop so every iteration gets a fresh array.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant