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

[async] aserver crashes on setting a property with invalid argument #87

Open
leiyu-bytedance opened this issue Nov 8, 2023 · 0 comments

Comments

@leiyu-bytedance
Copy link
Contributor

leiyu-bytedance commented Nov 8, 2023

With below simple example aserver that serving properties:

#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/async.hpp>
#include <xyz/openbmc_project/State/BMC/aserver.hpp>

PHOSPHOR_LOG2_USING;

constexpr auto service = "foo.bar.my_bmc_state";
constexpr auto objectPath = "/foo/bar/my_bmc_state_object";

class AsyncBMCServer : public sdbusplus::aserver::xyz::openbmc_project::state::BMC<AsyncBMCServer>
{
  public:
    explicit AsyncBMCServer(sdbusplus::async::context& ctx, auto path) :
        sdbusplus::aserver::xyz::openbmc_project::state::BMC<AsyncBMCServer>(ctx, path)
    {}

    // getter
    BMCState get_property(current_bmc_state_t) const
    {
        auto state = current_bmc_state_;
        info("currentBMCState getter: {STATE}", "STATE", state);
        return state;
    }

    // setter
    bool set_property(current_bmc_state_t, BMCState state)
    {
        bool changed = (state != current_bmc_state_);
        current_bmc_state_ = state;
        info("currentBMCState setter: {STATE}", "STATE", state);
        return changed;
    }
};

int main(int /*argc*/, char** /*argv*/)
{
    sdbusplus::async::context ctx;
    sdbusplus::server::manager_t manager{ctx, objectPath};

    AsyncBMCServer bmcServer(ctx, objectPath);

    ctx.spawn([](sdbusplus::async::context& ctx) -> sdbusplus::async::task<> {
        ctx.get_bus().request_name(service);
        co_return;
    }(ctx));

    info("Created AsyncBMCServer service on DBus");

    ctx.run();
    return 0;
}

On setting a property with invalid string, it crashes:

busctl set-property foo.bar.my_bmc_state /foo/bar/my_bmc_state_object xyz.openbmc_project.State.BMC CurrentBMCState s "InvalidString"
terminate called without an active exception

The coredump running on a x86 container:

#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007f3d3a0c43b6 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007f3d3a0aa87c in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007f3d3a357ee6 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007f3d3a369e9c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007f3d3a369f07 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#8  0x00007f3d3a60ebb6 in sdbusplus::async::details::wait_process_completion::arm (this=<optimized out>) at ../src/async/context.cpp:268
#9  0x00007f3d3a612395 in std::__n4861::coroutine_handle<void>::resume (this=0x7f3d34000c38) at /usr/include/c++/13/coroutine:135
#10 stdexec::__as_awaitable::tag_invoke<stdexec::__receivers::set_value_t> (__self=...) at ../include/sdbusplus/async/stdexec/../stdexec/execution.hpp:2101
#11 stdexec::__tag_invoke::tag_invoke_t::operator()<stdexec::__receivers::set_value_t, stdexec::__as_awaitable::__receiver<stdexec::_Yp<exec::__task::basic_task<void, exec::__task::__default_task_context_impl<(exec::__task::__scheduler_affinity)0> >::__promise>, void>::__t> (__tag=..., this=<optimized out>) at ../include/sdbusplus/async/stdexec/../stdexec/functional.hpp:138
#12 stdexec::__receivers::set_value_t::operator()<stdexec::__as_awaitable::__receiver<stdexec::_Yp<exec::__task::basic_task<void, exec::__task::__default_task_context_impl<(exec::__task::__scheduler_affinity)0> >::__promise>, void>::__t> (__rcvr=..., this=<optimized out>) at ../include/sdbusplus/async/stdexec/../stdexec/execution.hpp:627
#13 stdexec::__loop::__operation<stdexec::__as_awaitable::__receiver<stdexec::_Yp<exec::__task::basic_task<void, exec::__task::__default_task_context_impl<(exec::__task::__scheduler_affinity)0> >::__promise>, void> >::__t::__execute_impl (__p=0x7f3d34000c18) at ../include/sdbusplus/async/stdexec/../stdexec/execution.hpp:5265
#14 0x00007f3d3a610f81 in stdexec::__loop::__task::__execute (this=0x7f3d34000c18) at ../include/sdbusplus/async/stdexec/../stdexec/execution.hpp:5238
#15 stdexec::__loop::run_loop::run (this=0x7ffe0d2a2870) at ../include/sdbusplus/async/stdexec/../stdexec/execution.hpp:5430
#16 sdbusplus::async::context::worker_run (this=0x7ffe0d2a27c0) at ../src/async/context.cpp:161
#17 0x00007f3d3a399363 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#18 0x00007f3d3a1176ba in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:444
#19 0x00007f3d3a1a5ff4 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:100
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