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

[shim] Uncatchable terminate called after throwing an instance of 'std::runtime_error' #427

Open
ronanjs opened this issue Dec 17, 2020 · 0 comments

Comments

@ronanjs
Copy link
Contributor

ronanjs commented Dec 17, 2020

When launching an application linked with the SHIM, and if openperf server is not ready, the application will crash with:

terminate called after throwing an instance of 'std::runtime_error'
  what():  Could not connect to socket server: No such file or directory

It does not seem to be possible to catch this error. I tried this, but it did not work:

int main(int argc, char const* argv[])
{
    sleep(1);
    bool connected = false;
    while (!connected) {
        try {
            int sd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
            if (sd < 0) {
                perror("socket(AF_PACKET, SOCK_RAW)");
                sleep(1);
            } else {
                connected = true;
                close(sd);
            }
        } catch (std::runtime_error& e) {
            std::cout << "Failed to open the socket: " << e.what();
            sleep(1);
        }
    }

    printf("Starting the server...\n");
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

1 participant