PLCnext / CppExamples

Collection of various C++ sample code for PLCnext Technology controllers.
MIT License
31 stars 20 forks source link

ThreadExample Issue after Download. #16

Closed OWarneke closed 3 years ago

OWarneke commented 3 years ago

The ThreadExample has an issue to start after a download. It is necesarry to reboot the PLC. to fix it.

PLC (21.0.0.35466) SDK (21.0.0.35466) plcncli 21.0.0.489 (21.0.0.489) Engineer 21.0.1

To Reproduce Steps to reproduce the behavior:

  1. download project to an empty plc
  2. notice application has not started
  3. see error
    18.02.21 15:45:46.176 Arp.Plc.Domain.Internal.PlcManager                           ERROR - Exception occurs while loading component 'Arp.Plc.Plm': basic_string::_M_construct null not valid
    18.02.21 15:45:46.177 Arp.Plc.Domain.Internal.PlcManager                           ERROR - Plc component 'Arp.Plc.Plm' returns false while LoadPlc(isChanging=false) was called.
    18.02.21 15:45:46.353 Arp.Plc.Domain.Internal.PlcManager                           ERROR - Reverted all yet loaded components.
  4. execute /etc/init.d/plcnext restart
  5. see error
    
    18.02.21 15:54:20.389 Arp.Plc.Domain.Internal.PlcManager                           ERROR - Exception occurs while loading plc component 'Arp.Plc.Plm': Exception of type 'Arp::System::Ve::Exceptions::VeException' was thrown
    StartThread: Could not set scheduling parameters, linux error code: Invalid argument
    at: /usr/lib/libArp.System.Ve.so(+0x26daa) [0xb662cdaa]
    at: Arp::System::Ve::Internal::Linux::ThreadService::StartThread()
    at: Arp::System::Commons::Threading::Thread::CreateThreadInternal(Arp::System::Commons::Threading::ThreadSettings const&)
    at: ThreadExample::ThreadExampleComponent::ThreadExampleComponent(Arp::System::Acf::IApplication&, Arp::BasicString<char, std::allocator<char> > const&)
    at: ThreadExample::ThreadExampleComponent::Create(Arp::System::Acf::IApplication&, Arp::BasicString<char, std::allocator<char> > const&)
    at: Arp::System::Acf::ComponentFactory::CreateComponent(Arp::System::Acf::IApplication&, Arp::BasicString<char, std::allocator<char> > const&, Arp::BasicString<char, std::allocator<char> > const&)
    at: Arp::Plc::Plm::Internal::AdapterFactory::CreateComponent(Arp::System::Acf::Internal::Sm::Config::Component const&) const
    at: Arp::Plc::Plm::Internal::AdapterFactory::CreateComponentAdapter(Arp::System::Acf::Internal::Sm::Config::Component const&) const
    at: Arp::Plc::Plm::Internal::PlmComponentManager::CreateComponent(Arp::System::Acf::Internal::Sm::Config::Component const&)
    at: Arp::Plc::Plm::Internal::PlmComponentManager::ProcessComponentConfig(Arp::System::Acf::Internal::Sm::Config::Component const&, bool)
    at: Arp::Plc::Plm::Internal::PlmComponentManager::LoadComponents(bool)
    at: Arp::Plc::Plm::PlmComponent::LoadPlc(bool)
    at: Arp::Plc::Domain::Internal::PlcComponentInfo::LoadPlc(bool)
    at: Arp::Plc::Domain::Internal::PlcManager::LoadPlcComponents(bool)
    at: Arp::Plc::Domain::Internal::PlcManager::LoadPlcInternal()
    at: Arp::Plc::Domain::PlcManagerComponent::LoadConfig()
    at: Arp::System::Acf::Internal::Pm::ProcessManager::LoadComponentConfig(Arp::System::Acf::IComponent&) const
    at: Arp::System::Acf::Internal::Pm::ProcessManager::LoadComponentConfig(Arp::BasicString<char, std::allocator<char> > const&) const
    at: Arp::System::Acf::Services::Internal::ProcessManagerServiceImpl::LoadComponentConfig(Arp::System::Rsc::Services::RscString<512> const&)
    at: Arp::System::Acf::Internal::Sm::ComponentsController::SetupComponentConfig(Arp::System::Acf::Internal::Sm::Data::ComponentExecutionData&)
    at: Arp::System::Acf::Internal::Sm::ComponentsController::SetupComponentsConfig()
    at: Arp::System::Acf::Internal::Sm::SystemManager::SetupSystem()
    at: Arp::System::Acf::Internal::ApplicationBase::SetupBasicComponents(Arp::System::Acf::Internal::ApplicationSetupKind, Arp::System::Acf::Internal::ProcessKind)
    at: Arp::System::Acf::Internal::ApplicationBase::Setup(Arp::System::Commons::Diagnostics::Logging::LogLevel, char const*)
    at: Arp::System::Acf::Internal::ApplicationBase::Main(int, char**, Arp::System::Commons::Diagnostics::Logging::LogLevel)
    at: Arp.System.Application(+0x2000c) [0x48200c]
    at: /lib/libc.so.6(__libc_start_main+0x97) [0xb666a9a4]

18.02.21 15:54:20.829 Arp.Plc.Domain.Internal.PlcManager ERROR - Reverted all yet loaded components.


5. Download again
6. See same error or sometimes SegV
7. /etc/init.d/plcnext restart
8. Application is running fine

**Expected behavior**
Run without issue after first download.
OWarneke commented 3 years ago

cause identified: ThreadSettings has not been initialized in the moment of Thread creation resulting in invalid object.

18-02-_2021_15-22-34 18-02-_2021_15-22-17

possible fix: 18-02-_2021_16-14-47

OWarneke commented 3 years ago

propsed Fix #17

martinboers commented 3 years ago

Fixed by #17.