Skip to content

Commit

Permalink
flamenco, runtime: handle failure to setup vm in bpf loader
Browse files Browse the repository at this point in the history
  • Loading branch information
topointon-jump committed Oct 22, 2024
1 parent 67a4e46 commit 9c61f1e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/flamenco/runtime/program/fd_bpf_loader_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ deploy_program( fd_exec_instr_ctx_t * instr_ctx,
/* is_deprecated */ 0,
/* direct mapping */ direct_mapping );
if ( FD_UNLIKELY( vm == NULL ) ) {
FD_LOG_ERR(( "NULL vm" ));
FD_LOG_WARNING(( "NULL vm" ));
return FD_EXECUTOR_INSTR_ERR_PROGRAM_ENVIRONMENT_SETUP_FAILURE;
}

int validate_result = fd_vm_validate( vm );
Expand Down Expand Up @@ -519,7 +520,12 @@ execute( fd_exec_instr_ctx_t * instr_ctx, fd_sbpf_validated_program_t * prog, uc
/* is_deprecated */ is_deprecated,
/* direct_mapping */ direct_mapping );
if ( FD_UNLIKELY( vm == NULL ) ) {
FD_LOG_ERR(( "null vm" ));
/* We throw an error here because it could be the case that the given heap_size > HEAP_MAX.
In this case, Agave fails the transaction but does not error out.
https://github.com/anza-xyz/agave/blob/574bae8fefc0ed256b55340b9d87b7689bcdf222/programs/bpf_loader/src/lib.rs#L1396 */
FD_LOG_WARNING(( "null vm" ));
return FD_EXECUTOR_INSTR_ERR_PROGRAM_ENVIRONMENT_SETUP_FAILURE;
}

#ifdef FD_DEBUG_SBPF_TRACES
Expand Down
5 changes: 4 additions & 1 deletion src/flamenco/vm/fd_vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ fd_vm_join( void * shmem );
/* fd_vm_init initializes the given fd_vm_t struct, checking that it is
not null and has the correct magic value.
It modifies the vm object and also returns the object for convenience. */
It modifies the vm object and also returns the object for convenience.
FIXME: we should split out the memory mapping setup from this function, so that it is
clearer out to deal with the resulting errors. */
fd_vm_t *
fd_vm_init(
fd_vm_t * vm,
Expand Down

0 comments on commit 9c61f1e

Please sign in to comment.