Skip to content

context.bits will not automatically switch when setting context.arch twice. #2498

@RocketMaDev

Description

@RocketMaDev

I was using IPython to do some quick poc work that time, first I switched context.arch to 'amd64' and assembled cdqe and then I suddenly would like to try what if I assemble cdqe in 32-bit mode. So I switched context.arch back to 'i386' and wanted to assemble, only to find an error: AttributeError: Invalid arch/bits combination: i386/64

Pwntools may can not handle context.arch correctly, it could change context.bits accordingly when first setting it. However, when setting context.arch the second time, context.bits left unchanged. I guess this bug is related to self._tls?

poc:

屏幕截图_20241111_003054

one more poc:

from pwn import *
print(f"{context.arch}/{context.bits}")
context.arch = 'amd64'
print(f"{context.arch}/{context.bits}")
context.arch = 'i386'
print(f"{context.arch}/{context.bits}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions