Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
8 Views

Enclave stack overflow and malloc

Hi! I am trying to allocate 1.8MB memory on the heap, with malloc, inside the enclave, then make an OCALL where I pass as parameter a [in, out] pointer(*message_in) to this allocated memory(size_t message_len = 1823577): 

 

 

	ocall_get_next_message_size(&res_len, message_len);
	free(message_in);
	message_in = (unsigned char*) malloc(*message_len + 2);
    ocall_get_next_message(&res_message, message_in, *message_len + 2, &len_in, &len_out, path, 512);

 

 

(*message_in has been allocated memory in the enclave before). 

And in the .edl file: 

 

 

[cdecl] int ocall_get_next_message_size([in, out]size_t *message_len);
[cdecl] int ocall_get_next_message([in,out, size=message_len]unsigned char *message_in,size_t message_len,[in,out] size_t *len_in, [in, out]size_t *len_out, [in, out, size=len] char* path, size_t len);
		

 

 

 

However, I get stack overflow on ocall_get_next_message:

Screenshot (87).png

 

I believe I have allocated enough memory on the stack:

Screenshot (84).png

 

Moreover, trying to increase the stack size(even only to 0x3600000) or the heap size more (still multiple of 4k) makes the program not start anymore:

Screenshot (86).png

 

I wanted to ask where could be the problem and what are the limitations of an enclave, besides the 128MB size. How much memory can pass a pointer to in an OCALL/ECALL and what is the maximum size my stack and heap can have?  I could not find information about this in the developer guide.

Thank you.

0 Kudos