Skip to content
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

OP_RETURN: line 526 Program received signal SIGSEGV, Segmentation fault. #1

Open
Immortality-IMT opened this issue Feb 18, 2024 · 0 comments

Comments

@Immortality-IMT
Copy link

Segmentation Fault on case OP_RETURN: line 526 Program received signal SIGSEGV, Segmentation fault.
0x00005555555568e1 in to_uint64 ()
.

uint8_t bytecode[] = {0x60, 0x02, 0x60, 0x02, 0x52, 0xf3};
size_t bytecode_size = sizeof(bytecode);

// Execute the bytecode
struct evmc_host_interface host;
struct evmc_host_context* context = NULL;
struct evmc_message msg;

struct evmc_result result = evm->execute(evm, &host, context, EVMC_SHANGHAI, &msg, bytecode, bytecode_size);

//print_stack();

printf("Execution result: %d\n", result.status_code);

Please provide a main() for the execution of bytecode testing. I am currently using int main() {
// Create an instance of the EVM
struct evmc_vm* evm = evmc_create();

printf("Name: %s\n", evm->name);
printf("Version: %s\n", evm->version);
// Retrieve and print the capabilities
printf("Capabilities: %d\n", evm->get_capabilities(evm));

// Define the bytecode for a simple addition operation: PUSH1 0x02, PUSH1 0x05, ADD

// uint8_t bytecode[] = {0x60, 0x02, 0x60, 0x05, 0x01, 0x00};
// uint8_t bytecode[] = {0x60, 0x2a, 0x00};
uint8_t bytecode[] = {0x60, 0x02, 0x60, 0x02, 0x52, 0xf3};
size_t bytecode_size = sizeof(bytecode);

// Execute the bytecode
struct evmc_host_interface host;
struct evmc_host_context* context = NULL;
struct evmc_message msg;

// Assuming you already have the `evm` instance created
struct evmc_result result = evm->execute(evm, &host, context, EVMC_SHANGHAI, &msg, bytecode, bytecode_size);

//print_stack();

// Print the execution result
printf("Execution result: %d\n", result.status_code);

/*
if (result.status_code == EVMC_SUCCESS && result.output_size > 0) {
printf("Output bytecode: ");
for (size_t i = 0; i < result.output_size; ++i) {
printf("%02X ", result.output_data[i]);
}
printf("\n");
}
*/
// Destroy the EVM instance
evm->destroy(evm);

return 0;

}

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

No branches or pull requests

1 participant