-
Notifications
You must be signed in to change notification settings - Fork 50
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
Debug is enabled but there is no output #273
Comments
Finally I fixed my bugs by |
Hi, I think CapturePFGPExceptions=1 doesn't work for all types of exceptions. Now that you know the bug, can you provide a minimal reproduction so that we can check if this is the case here? |
Minimal sample codeI called a function from a library written in C using cgo. This function caused the program to crash. It allocates a block of memory via mmap and then writes the base address of that memory to the GS register. It was precisely this action of writing to the GS register that led to the "ERROR: signal: segmentation fault (core dumped)". The program ran normally after I removed the line This is a sample. package main
import "fmt"
/*
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
// write base addr of memory to GS segment register
#define os_writegsbase(base_addr) \
do { \
uint64_t __gs_value = (uint64_t)(uint64_t *)base_addr; \
asm volatile("wrgsbase %0" ::"r"(__gs_value) : "memory"); \
} while (0)
int mmap_function() {
uint64_t new_size = 128 * 1024 * 1024; // 128 MB
void *new_mem =
mmap(NULL, new_size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
#if defined(os_writegsbase)
// the code crashed here in sgx mode
os_writegsbase(new_mem);
#endif
if (new_mem == MAP_FAILED) {
perror("mmap error");
return -1;
}
munmap(new_mem, new_size);
return 0;
}
*/
import "C"
// the wrapper to call function in C
func CallMmapFunction() int {
res := C.mmap_function()
return int(res)
}
func main() {
res := CallMmapFunction()
fmt.Println(res)
} To reproduceThe enclave.json is the same as the one I mentioned above.
|
Regarding SIGILL, see https://docs.edgeless.systems/ego/workflows/debug#inside-an-enclave Thanks for the sample code. This can be tricky to debug. The gs register is used by the SGX runtime. If it is modified by the app, the runtime will most probably crash the next time it reads the register and uses the value. You can see the location of the crash in ego-gdb, but it's not obvious what caused it. |
Issue description
Hi,
When I run my application, I encounter the following error message. I have set
"debug": true
in enclave.json, but it didn't work for me.I also tried https://docs.edgeless.systems/ego/reference/config#advanced-users-tweak-underlying-enclave-configuration, it didn't work too.
This my enclave.json
And this is the enclave.conf.
Could anyone give me some advice to debug this?
To reproduce
Steps to reproduce the behavior:
By the way, in step 4, I got
segmentation fault
. But in step 5, the application executes normally.The text was updated successfully, but these errors were encountered: