[runtime error] runtime error: load of null pointer of type 'int'

547 views
Skip to first unread message

张泽民

<evansun0312@gmail.com>
unread,
Mar 17, 2022, 6:20:40 AM3/17/22
to seastar-dev
1. Here is my test code:

int main(int args, char** argv, char** env) {
    seastar::app_template app;
    return app.run(args, argv, [&] {
        auto fut1 = seastar::thread([] {
            std::cout << "test 1" << std::endl;
        });

        return seastar::async([&] {
            std::cout << "test 2" << std::endl;
        });
    });
}

it got errors like:
error2.png

2. But if add a then() after async() :

int main(int args, char** argv, char** env) {
    seastar::app_template app;
    return app.run(args, argv, [&] {
        auto fut1 = seastar::thread([] {
            std::cout << "test 1" << std::endl;
        });

        return seastar::async([&] {
            std::cout << "test 2" << std::endl;
        }).then([] {
            std::cout << "test 3" << std::endl;
        });
    });
}
It runs well:
error1.png

3. FYI:

There is a comment is utils/critical_alloc_section.hh:


Is this the reason?
My gcc version is 11.2.0.

Benny Halevy

<bhalevy@scylladb.com>
unread,
Mar 17, 2022, 7:01:44 AM3/17/22
to 张泽民, seastar-dev
it looks like fut1 is running in the backgroung without anyone waiting for it.

Add e.g. fut1.get(); inside the async block should do it.

--
You received this message because you are subscribed to the Google Groups "seastar-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seastar-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/seastar-dev/28b17871-80a8-4155-9c56-138ee53534e8n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages