Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix a bug in cptr_to_u64 in emulation #2172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

certik
Copy link
Contributor

@certik certik commented Jul 17, 2023

No description provided.

@certik
Copy link
Contributor Author

certik commented Jul 17, 2023

Let's write a test for this as well, and investigate if the other function also needs this (update: it does, see commit below).

@ronnuriel
Copy link
Collaborator

Let's write a test for this as well, and investigate if the other function also needs this (update: it does, see commit below).

Hey I tested it and its not working,
return ctypes.addressof(cptr)
TypeError: invalid type

@ronnuriel
Copy link
Collaborator

ronnuriel commented Jul 18, 2023

Proposal:
@certik

def cptr_to_u64(cptr):
    return u64(ctypes.cast(cptr, ctypes.c_void_p).value)

def u64_to_cptr(ivalue):
    return ctypes.c_void_p(i64(ivalue))

Tested and works

@certik
Copy link
Contributor Author

certik commented Jul 19, 2023

@ronnuriel, awesome thanks. I submitted it here with you as an author: #2186. It would be nice to figure out an isolated test for this but it's more important to fix it, so if it passes, we'll merge it. Closing in favor of #2186.

@certik certik closed this Jul 19, 2023
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.

2 participants