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

Seg fault when reading the Networks attribute (linux) #19585

Closed
cecille opened this issue Jun 14, 2022 · 0 comments · Fixed by #19588
Closed

Seg fault when reading the Networks attribute (linux) #19585

cecille opened this issue Jun 14, 2022 · 0 comments · Fixed by #19588

Comments

@cecille
Copy link
Contributor

cecille commented Jun 14, 2022

Problem

Attempting to read the Network attribute from a linux device where the networks have been added but not connected results in a seg fault.

Proposed Solution

This appears to be happening because the code assumes where is a connected interface. Need to add checks around that condition.

bt:
Thread 1 "chip-all-cluste" received signal SIGSEGV, Segmentation fault.
0x00005555557163dd in wpa_fi_w1_wpa_supplicant1_interface_get_current_network (object=0x0) at gen/include/platform/Linux/dbus/wpa/DBusWpaInterface.c:6434
6434 return WPA_FI_W1_WPA_SUPPLICANT1_INTERFACE_GET_IFACE (object)->get_current_network (object);
(gdb) bt
#0 0x00005555557163dd in wpa_fi_w1_wpa_supplicant1_interface_get_current_network (object=0x0) at gen/include/platform/Linux/dbus/wpa/DBusWpaInterface.c:6434
#1 0x00005555556ee4f7 in chip::DeviceLayer::ConnectivityManagerImpl::GetConfiguredNetwork(chip::DeviceLayer::NetworkCommissioning::Network&)
(this=0x55555580f420 chip::DeviceLayer::ConnectivityManagerImpl::sInstance, network=...) at ../../third_party/connectedhomeip/src/platform/Linux/ConnectivityManagerImpl.cpp:1349
#2 0x00005555556f619e in chip::DeviceLayer::NetworkCommissioning::LinuxWiFiDriver::WiFiNetworkIterator::Next(chip::DeviceLayer::NetworkCommissioning::Network&)
(this=0x5555558862b0, item=...) at ../../third_party/connectedhomeip/src/platform/Linux/NetworkCommissioningWiFiDriver.cpp:210
#3 0x00005555555e7567 in operator()chip::app::AttributeValueEncoder::ListEncodeHelper(chip::app::AttributeValueEncoder::ListEncodeHelper const&) const
(__closure=0x7fffffffbb08, encoder=...) at ../../third_party/connectedhomeip/src/app/clusters/network-commissioning/network-commissioning.cpp:150
#4 0x00005555555e763f in chip::app::AttributeValueEncoder::EncodeList<chip::app::Clusters::NetworkCommissioning::Instance::Read(const chip::app::ConcreteReadAttributePath&, chip::app::AttributeValueEncoder&)::<lambda(const auto:10&)> >(struct {...}) (this=0x7fffffffbc40, aCallback=...) at ../../third_party/connectedhomeip/src/app/AttributeAccessInterface.h:227
#5 0x00005555555e4154 in chip::app::Clusters::NetworkCommissioning::Instance::Read(chip::app::ConcreteReadAttributePath const&, chip::app::AttributeValueEncoder&)
(this=0x555555807fe0 <(anonymous namespace)::sWiFiNetworkCommissioningInstance>, aPath=..., aEncoder=...)
at ../../third_party/connectedhomeip/src/app/clusters/network-commissioning/network-commissioning.cpp:145
#6 0x000055555559e794 in chip::app::(anonymous namespace)::ReadViaAccessInterface(chip::FabricIndex, bool, chip::app::ConcreteReadAttributePath const&, chip::app::AttributeReportIBs::Builder&, chip::app::AttributeValueEncoder::AttributeEncodeState*, chip::app::AttributeAccessInterface*, bool*)
(aAccessingFabricIndex=1 '\001', aIsFabricFiltered=true, aPath=..., aAttributeReports=..., aEncoderState=0x7fffffffc3dc, aAccessInterface=0x555555807ff8 <(anonymous namespace)::sWiFiNetworkCommissioningInstance+24>, aTriedEncode=0x7fffffffc17f) at ../../third_party/connectedhomeip/src/app/util/ember-compatibility-functions.cpp:476
#7 0x000055555559ec62 in chip::app::ReadSingleClusterData(chip::Access::SubjectDescriptor const&, bool, chip::app::ConcreteReadAttributePath const&, chip::app::AttributeReportIBs::Builder&, chip::app::AttributeValueEncoder::AttributeEncodeState*) (aSubjectDescriptor=..., aIsFabricFiltered=true, aPath=..., aAttributeReports=..., apEncoderState=0x7fffffffc3dc)
at ../../third_party/connectedhomeip/src/app/util/ember-compatibility-functions.cpp:579
#8 0x0000555555677d03 in chip::app::reporting::Engine::RetrieveClusterData(chip::Access::SubjectDescriptor const&, bool, chip::app::AttributeReportIBs::Builder&, chip::app::ConcreteReadAttributePath const&, chip::app::AttributeValueEncoder::AttributeEncodeState*)
(this=0x55555580d370 chip::app::sInteractionModelEngine+1200, aSubjectDescriptor=..., aIsFabricFiltered=true, aAttributeReportIBs=..., aPath=..., aEncoderState=0x7fffffffc3dc)
at ../../third_party/connectedhomeip/src/app/reporting/Engine.cpp:81
#9 0x000055555567810f in chip::app::reporting::Engine::BuildSingleReportDataAttributeReportIBs(chip::app::ReportDataMessage::Builder&, chip::app::ReadHandler*, bool*, bool*)
(this=0x55555580d370 chip::app::sInteractionModelEngine+1200, aReportDataBuilder=..., apReadHandler=0x555555865eb0, apHasMoreChunks=0x7fffffffc753, apHasEncodedData=0x7fffffffc751) at ../../third_party/connectedhomeip/src/app/reporting/Engine.cpp:179
#10 0x000055555567948c in chip::app::reporting::Engine::BuildAndSendSingleReportData(chip::app::ReadHandler*)
(this=0x55555580d370 chip::app::sInteractionModelEngine+1200, apReadHandler=0x555555865eb0) at ../../third_party/connectedhomeip/src/app/reporting/Engine.cpp:463
#11 0x0000555555679dc2 in chip::app::reporting::Engine::Run() (this=0x55555580d370 chip::app::sInteractionModelEngine+1200)
at ../../third_party/connectedhomeip/src/app/reporting/Engine.cpp:591
#12 0x0000555555679af8 in chip::app::reporting::Engine::Run(chip::System::Layer*, void*)
(aSystemLayer=0x55555580eac0 chip::DeviceLayer::SystemLayerImpl()::gSystemLayerImpl, apAppState=0x55555580d370 chip::app::sInteractionModelEngine+1200)
at ../../third_party/connectedhomeip/src/app/reporting/Engine.cpp:542
#13 0x000055555579b557 in chip::System::TimerData::Callback::Invoke() const (this=0x7fffffffcdd0) at ../../third_party/connectedhomeip/src/system/SystemTimer.h:61
#14 0x000055555579cb41 in chip::System::TimerPoolchip::System::TimerList::Node::Invoke(chip::System::TimerList::Node*)
(this=0x55555580f0c8 chip::DeviceLayer::SystemLayerImpl()::gSystemLayerImpl+1544, timer=0x555555886730) at ../../third_party/connectedhomeip/src/system/SystemTimer.h:224
#15 0x000055555579c76a in chip::System::LayerImplSelect::HandleEvents() (this=0x55555580eac0 chip::DeviceLayer::SystemLayerImpl()::gSystemLayerImpl)
at ../../third_party/connectedhomeip/src/system/SystemLayerImplSelect.cpp:397
#16 0x00005555556f7516 in chip::DeviceLayer::Internal::GenericPlatformManagerImpl_POSIXchip::DeviceLayer::PlatformManagerImpl::_RunEventLoop()
(this=0x55555580f630 chip::DeviceLayer::PlatformManagerImpl::sInstance+16)
at ../../third_party/connectedhomeip/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp:181
#17 0x000055555558f32a in chip::DeviceLayer::PlatformManager::RunEventLoop() (this=0x55555580f620 chip::DeviceLayer::PlatformManagerImpl::sInstance)
at ../../third_party/connectedhomeip/src/include/platform/PlatformManager.h:362
#18 0x000055555559176c in ChipLinuxAppMainLoop() () at ../../third_party/connectedhomeip/examples/platform/linux/AppMain.cpp:329
#19 0x000055555557d652 in main(int, char**) (argc=2, argv=0x7fffffffd0b8) at ../../main.cpp:30

cecille added a commit to cecille/connectedhomeip that referenced this issue Jun 14, 2022
This happens when running the example apps on linux with the wifi
feature enabled (--wifi) because the device is actually connected
via ethernet and wifi is not connected. This could happen in a prod
device if > 1 network type was supported.

Fixes project-chip#19585
andy31415 pushed a commit that referenced this issue Jun 16, 2022
* Fix crash on read Networks when not connected

This happens when running the example apps on linux with the wifi
feature enabled (--wifi) because the device is actually connected
via ethernet and wifi is not connected. This could happen in a prod
device if > 1 network type was supported.

Fixes #19585

* Restyled by clang-format

Co-authored-by: Restyled.io <commits@restyled.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants