- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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:
I believe I have allocated enough memory on the stack:
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:
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.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi, Jesus. I've solved the problem. Looks like the stack overflow came from copying the buffer to the untrusted stack. Apparently, Visual Studio set the untrusted stack size to 1MB by default. Increasing the stack reserve size to more than 2MB solved the issue.
Link kopiert
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hello Anna,
We are looking into your issue. Please stay tuned.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hello Anna,
I was able to reproduce your issue but not solve it. You must have enough space in your EPC for SGX Enclave Control Structure, Thread Control Structure, Save State Area, Stack, Heap, and Code and Data. I noticed that decreasing the size of the allocated buffer to a little more than 1000000 made the allocation successful. I could not find a max stack and heap size config that would allow your size of buffer.
Have you verified in your BIOS how much Processor Reserved Memory you have?
Regards,
Jesus
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi Anna, we are still looking into this issue. I apologize for the delay.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi, Jesus. I've solved the problem. Looks like the stack overflow came from copying the buffer to the untrusted stack. Apparently, Visual Studio set the untrusted stack size to 1MB by default. Increasing the stack reserve size to more than 2MB solved the issue.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Thanks for sharing the solution, Anna. I'm glad you got it working.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi Anna, I have been playing around with the C++ option /F and setting the linker options for stack reserve and commit sizes but I still cannot get the program to work. I got around the stack overflow but run into a different error.
Would you mind telling us what specifically you changed to resolve the issue?
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi Jesus,
For the stack reserve memory:
I selected the untrusted app project and then went to Proprieties->Configuration Proprieties->Linker->System->Stack Reserve Size and increased the stack size to 4MB at first at think, and it solved the issue.
I don't recall having another problem around here after that, my code is compiling and working now (the same code I posted here). The enclave memory settings are: stack - 0x4000, heap 0x2000000. I have been able to copy chunks of 10MB, 20 MB and more back and forth.
Anna

- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite