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

entity-manager terminated by 'std::filesystem::__cxx11::filesystem_error' #8

Closed
leiyu-bytedance opened this issue Apr 20, 2021 · 4 comments

Comments

@leiyu-bytedance
Copy link

The issue is found by g220a's QEMU, that the entity-manager is terminated by 'std::filesystem::__cxx11::filesystem_error':

Jan 01 00:00:47 g220a entity-manager[312]: Clearing previous configuration
Jan 01 00:01:35 g220a entity-manager[312]: configuration file missing probe:
Jan 01 00:01:35 g220a entity-manager[312]:  {"buses":[]}
Jan 01 00:01:36 g220a entity-manager[312]: Inventory Added
Jan 01 00:01:36 g220a entity-manager[312]: terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'
Jan 01 00:01:36 g220a entity-manager[312]:   what():  filesystem error: recursive directory iterator cannot open directory: No such file or directory [/sys/bus/i2c/devices/i2c-26]

The issue is introduced by 9b86787, if we revert the commit, the issue is gone.

@Jayashree-D
Copy link
Contributor

I am also facing this issue in tiogapass.

root@tiogapass:~# systemctl status xyz.openbmc_project.EntityManager.service -l
● xyz.openbmc_project.EntityManager.service - Entity Manager
Loaded: loaded (�]8;;file://tiogapass/lib/systemd/system/xyz.openbmc_project.EntityManager.service/lib/systemd/system/xyz.openbmc_project.EntityManager.service�]8;;; enabled; vendor preset: enabled)
Active: active (running) since Thu 1970-01-01 00:04:10 UTC; 25s ago
Process: 851 ExecStartPre=/bin/mkdir -p /var/configuration (code=exited, status=0/SUCCESS)
Process: 852 ExecStartPre=/bin/mkdir -p /tmp/overlays (code=exited, status=0/SUCCESS)
Main PID: 853 (entity-manager)
CGroup: /system.slice/xyz.openbmc_project.EntityManager.service
└─853 /usr/bin/entity-manager

Jan 01 00:04:09 tiogapass systemd[1]: Starting Entity Manager...
Jan 01 00:04:10 tiogapass systemd[1]: Started Entity Manager.
Jan 01 00:04:27 tiogapass entity-manager[853]: Inventory Added
Jan 01 00:04:27 tiogapass entity-manager[853]: terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'
Jan 01 00:04:27 tiogapass entity-manager[853]: what(): filesystem error: recursive directory iterator cannot open directory: No such file or directory [/sys/bus/i2c/devices/i2c-16]

@leiyu-bytedance
Copy link
Author

Here is the full stack back trace:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  0x76b26f10 in __GI_abort () at abort.c:79
#2  0x76dabf60 in __gnu_cxx::__verbose_terminate_handler () at ../../../../../../../../../work-shared/gcc-10.2.0-r0/gcc-10.2.0/libstdc++-v3/libsupc++/vterminate.cc:95
#3  0x76da9aec in __cxxabiv1::__terminate (handler=<optimized out>) at ../../../../../../../../../work-shared/gcc-10.2.0-r0/gcc-10.2.0/libstdc++-v3/libsupc++/eh_terminate.cc:48
#4  0x76da9b78 in std::terminate () at ../../../../../../../../../work-shared/gcc-10.2.0-r0/gcc-10.2.0/libstdc++-v3/libsupc++/eh_terminate.cc:58
#5  0x76da9f30 in __cxxabiv1::__cxa_throw (obj=obj@entry=0x1e32ae0, tinfo=0x76eae188 <typeinfo for std::filesystem::__cxx11::filesystem_error>,
    dest=0x76e643bc <std::filesystem::__cxx11::filesystem_error::~filesystem_error()>) at ../../../../../../../../../work-shared/gcc-10.2.0-r0/gcc-10.2.0/libstdc++-v3/libsupc++/eh_throw.cc:95
#6  0x76e591bc in std::filesystem::__cxx11::recursive_directory_iterator::recursive_directory_iterator (this=0x7eb50424, p=..., options=<optimized out>, ecptr=<optimized out>)
    at /usr/src/debug/gcc-runtime/10.2.0-r0/arm-openbmc-linux-gnueabi/libstdc++-v3/include/ext/new_allocator.h:89
#7  0x00525b50 in std::filesystem::__cxx11::recursive_directory_iterator::recursive_directory_iterator (__p=..., this=0x7eb5041c) at /usr/include/c++/10.2.0/bits/fs_dir.h:473
#8  deviceIsCreated (devicePath=..., bus=..., address=..., retrying=retrying@entry=false) at ../git/src/Overlay.cpp:172
#9  0x00528184 in buildDevice (devicePath=..., parameters=..., bus=..., address=..., constructor=..., destructor=..., createsHWMon=true, createsHWMon@entry=156, retries=retries@entry=5)
    at ../git/src/Overlay.cpp:236
#10 0x0052986c in exportDevice (type=..., exportTemplate=..., configuration=...) at ../git/src/Overlay.cpp:322
#11 0x0052a91c in loadOverlays (systemConfiguration=...) at ../git/src/Overlay.cpp:363
#12 0x004a7670 in operator() (__closure=0x7eb50a78) at ../git/src/EntityManager.cpp:1830
#13 boost::asio::asio_handler_invoke<propertiesChangedCallback(nlohmann::json&, sdbusplus::asio::object_server&)::<lambda(const boost::system::error_code&)>::<lambda()>::<lambda()> > (
    function=...) at /usr/include/boost/asio/handler_invoke_hook.hpp:88
#14 boost_asio_handler_invoke_helpers::invoke<propertiesChangedCallback(nlohmann::json&, sdbusplus::asio::object_server&)::<lambda(const boost::system::error_code&)>::<lambda()>::<lambda()>, propertiesChangedCallback(nlohmann::json&, sdbusplus::asio::object_server&)::<lambda(const boost::system::error_code&)>::<lambda()>::<lambda()> > (context=..., function=...)
    at /usr/include/boost/asio/detail/handler_invoke_helpers.hpp:54
#15 boost::asio::detail::handler_work<propertiesChangedCallback(nlohmann::json&, sdbusplus::asio::object_server&)::<lambda(const boost::system::error_code&)>::<lambda()>::<lambda()>, boost::asio::io_context::basic_executor_type<std::allocator<void>, 0>, void>::complete<propertiesChangedCallback(nlohmann::json&, sdbusplus::asio::object_server&)::<lambda(const boost::system::error_code&)>::<lambda()>::<lambda()> > (handler=..., function=..., this=<synthetic pointer>) at /usr/include/boost/asio/detail/handler_work.hpp:425
#16 boost::asio::detail::completion_handler<propertiesChangedCallback(nlohmann::json&, sdbusplus::asio::object_server&)::<lambda(const boost::system::error_code&)>::<lambda()>::<lambda()>, boost::asio::io_context::basic_executor_type<std::allocator<void>, 0> >::do_complete(void *, boost::asio::detail::operation *, const boost::system::error_code &, std::size_t) (
    owner=owner@entry=0x1da7150, base=0x1da8d58) at /usr/include/boost/asio/detail/completion_handler.hpp:74
#17 0x0049da0c in boost::asio::detail::scheduler_operation::complete (bytes_transferred=0, ec=..., owner=0x1da7150, this=<optimized out>)
    at /usr/include/boost/asio/detail/scheduler_operation.hpp:40
#18 boost::asio::detail::scheduler::do_run_one (ec=..., this_thread=..., lock=..., this=0x1da7150) at /usr/include/boost/asio/detail/impl/scheduler.ipp:481
#19 boost::asio::detail::scheduler::run (ec=..., this=0x1da7150) at /usr/include/boost/asio/detail/impl/scheduler.ipp:204
#20 boost::asio::io_context::run (this=0x5c326c <io>, this=0x5c326c <io>) at /usr/include/boost/asio/impl/io_context.ipp:63
#21 main () at ../git/src/EntityManager.cpp:1970

@edtanous
Copy link
Contributor

I suspect this is the fix, although to hit this failure, your config files would need to reference a bus that doesn't exist, so I'm guessing this wont fix your system itself, it will just avoid the crash.
https://gerrit.openbmc-project.xyz/c/openbmc/entity-manager/+/42813

bradbishop pushed a commit that referenced this issue May 3, 2021
This is a fix to a regression introduced as part of
9b86787
namely, the recursive iterator doesn't check for the existence of a bus
path before attempting to open it, which results in a crash when
std::filesystem throws an exception.

This was reported as part of bug #8

Tested:
Launched entity-manager in qemu, which was previously crashing and
observed "Unable to open path /sys/bus/i2c/devices/i2c-4" in the journal
log, with entity-manager staying running.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I638a66e271df0041d4df75be22eb03c064d9cf68
@edtanous
Copy link
Contributor

edtanous commented May 4, 2021

I'm closing as this has been merged. If this is still an issue, please reopen.

@edtanous edtanous closed this as completed May 4, 2021
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

3 participants