You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@teaclave.apache.org by GitBox <gi...@apache.org> on 2020/06/23 00:26:01 UTC

[GitHub] [incubator-teaclave-sgx-sdk] duanbing edited a comment on issue #251: libc::free core dump due to invalid address

duanbing edited a comment on issue #251:
URL: https://github.com/apache/incubator-teaclave-sgx-sdk/issues/251#issuecomment-647835021


   > > ```
   > > void ocall_free([user_check]void* p);
   > > -----
   > > #[no_mangle]
   > > pub extern "C" fn ocall_free(p: *mut libc::c_void) {
   > >    println!("addr: {:?}", p);
   > >    unsafe { libc::free(p) }
   > > }   
   > > ```
   > 
   > before you call `ocall-free`, what is the pointer's value? is it pointing to an unsafe buffer? can i pass the sgx_is_outside_enclave check?
   
   ```
   ....
           let mut output = 0 as *mut libc::c_void;
          
           let mut out_len: usize = 0;
           let resp = unsafe {
               ocall_call(&mut rt,
                                          req.as_ptr() as *const u8,
                                          req.len(),
                                          &mut output,
                                          &mut out_len)
           };
          
           // TODO resp和rt都要判断
           match resp {
               sgx_status_t::SGX_SUCCESS => {
                   ....
                  
                   println!("before free: {:?}", output);
                   let mut rt : sgx_status_t = sgx_status_t::SGX_ERROR_UNEXPECTED;
                   unsafe{ocall_free(&mut rt, output)};
                   ..
   
                   Ok(xxxx)
               },
   ...
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@teaclave.apache.org
For additional commands, e-mail: notifications-help@teaclave.apache.org