Skip to content
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

sgx_emmt shows 0KB #237

Open
gmatesunny opened this issue Mar 28, 2018 · 2 comments
Open

sgx_emmt shows 0KB #237

gmatesunny opened this issue Mar 28, 2018 · 2 comments

Comments

@gmatesunny
Copy link

gmatesunny commented Mar 28, 2018

Related to closed issue #136
I have a mbed-sgx server(multi-threaded) that sets up the ssl context inside enclave and the infinite loop to accept connection runs at the app and does some analysis inside the enclave. It stops on SIGINT signal.

Related Server code snippet.

    std::signal(SIGINT, exitGraceful);
    do {

        std::this_thread::sleep_for (std::chrono::seconds(1));
        if (quit.load()) {
            cerr << "APP: Ctrl-C/SIGINT passed.\n" << endl;
            break;
        }
     mbedtls_net_accept(&listen_fd, &client_fd, NULL, 0, NULL);
   } while(true);
    mbedtls_printf("APP: About to exit\n");
    sgx_destroy_enclave(eid);
    return (ret);
}

So I wanted to calculate max stack size and heap size. I did this:
Terminal 1:
run my server
Terminal 2:
run sgx-gdb

enable sgx_emmt
attach 3975(pid of my server )
continue &

Terminal 3:
I send a request to the server and the server send reponse.

Now, on Terminal 1, I press Ctrl+C, nothing happens and the server does not exits but gdb on terminal 1 prints:

Thread 1 "osn_server" received signal SIGINT, Interrupt.
0x00007f4ffbc7fc1d in nanosleep () at ../sysdeps/unix/syscall-template.S:84
84	in ../sysdeps/unix/syscall-template.S

After that on gdb I do:
signal 2
and now my server terminates and gdb prints

Enclave: "/home/roshan/thesis/osn_server/sgx/enclave_enclave/enclave.signed.so"
  [Peak stack used]: 0 KB
  [Can't get peak heap used]: You may use version script to control symbol export. Please export 'g_peak_heap_used' in your version script.
remove-symbol-file -a 139978543850752
[Inferior 1 (process 3975) exited normally]

If I do not do [Terminal 1, I press Ctrl+C] and directly write signal 2 in gdb, nothing happens to the server and it continues to run and gdb prints:
Cannot execute this command without a live selected thread.

Why the stack size prints 0KB and the how I get peak heap used. Am I doing the things in the correct way?

PS: I am using SIM mode.

@llly
Copy link
Contributor

llly commented Mar 29, 2018

sgx_destroy_enclave must be called to get stack and heap usage. It seem that the server is terminated without destroy the enclave. You can add a signal handler to destroy the enclaves that you want to measure when SIGINT received.

@gmatesunny
Copy link
Author

I have added signal handler as well as sgx_destroy_enclave call.

std::signal(SIGINT, exitGraceful);
sgx_destroy_enclave(eid);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants