Skip to content

Commit

Permalink
Merge pull request eclipse-iceoryx#65 in AOS/iceoryx_eclipse from bug…
Browse files Browse the repository at this point in the history
…fix/AOS-13229-carma-0.20.0-develop-rc-roudi-segfault-in-introspection-mempool-port to develop

* commit '0d03970002c09eb7342884a99b1dee4d25b54b2f':
  AOS-13229 remark, remove general name Topic
  AOS-13229 fix introspections shm segments view feature and remove the segfault cause by the introspection
  • Loading branch information
sculpordwarf committed Oct 28, 2020
2 parents ab2cb85 + 0d03970 commit fed851f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class MemPoolIntrospection
TERMINATE
};

using Topic = MemPoolIntrospectionInfoContainer;

public:
/**
* @brief The constructor for the MemPoolIntrospection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,33 +134,44 @@ void MemPoolIntrospection<MemoryManager, SegmentManager, SenderPort>::send() noe
if (m_senderPort.hasSubscribers())
{
uint32_t id = 0;

auto chunkHeader = m_senderPort.reserveChunk(sizeof(Topic));
auto sample = static_cast<Topic*>(chunkHeader->payload());
new (sample) Topic;
auto chunkHeader = m_senderPort.reserveChunk(sizeof(MemPoolIntrospectionInfoContainer));
auto sample = static_cast<MemPoolIntrospectionInfoContainer*>(chunkHeader->payload());
new (sample) MemPoolIntrospectionInfoContainer;

if (sample->emplace_back())
{
// RouDi's shm segment
auto& memPoolIntrospectionInfo = sample->back();

prepareIntrospectionSample(memPoolIntrospectionInfo,
posix::PosixGroup::getGroupOfCurrentProcess(),
posix::PosixGroup::getGroupOfCurrentProcess(),
id);
copyMemPoolInfo(*m_rouDiInternalMemoryManager, memPoolIntrospectionInfo.m_mempoolInfo);
++id;

// User shm segments
for (auto& segment : m_segmentManager->m_segmentContainer)
{
if (sample->emplace_back())
{
auto& memPoolIntrospectionInfo = sample->back();
prepareIntrospectionSample(
memPoolIntrospectionInfo, segment.getReaderGroup(), segment.getWriterGroup(), id);
copyMemPoolInfo(segment.getMemoryManager(), memPoolIntrospectionInfo.m_mempoolInfo);
}
else
{
LogWarn() << "Mempool Introspection Container full, Mempool Introspection Data not fully updated! "
<< (id + 1) << " of " << m_segmentManager->m_segmentContainer.size()
<< " memory segments sent.";
break;
}
++id;

prepareIntrospectionSample(
memPoolIntrospectionInfo, segment.getReaderGroup(), segment.getWriterGroup(), id);
copyMemPoolInfo(segment.getMemoryManager(), memPoolIntrospectionInfo.m_mempoolInfo);
}
}
else
{
LogError() << "Mempool Introspection Container full, Mempool Introspection Data not updated!";
LogWarn() << "Mempool Introspection Container full, Mempool Introspection Data not updated!";
}

m_senderPort.deliverChunk(chunkHeader);
Expand Down
3 changes: 1 addition & 2 deletions tools/introspection/source/introspection_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ void IntrospectionApp::runIntrospection(const iox::units::Duration updatePeriodM
SubscriberType memPoolSubscriber(IntrospectionMempoolService);
if (introspectionSelection.mempool == true)
{
memPoolSubscriber.subscribe(iox::MAX_SHM_SEGMENTS + 1u);
memPoolSubscriber.subscribe(1u);

if (waitForSubscription(memPoolSubscriber) == false)
{
Expand All @@ -626,7 +626,6 @@ void IntrospectionApp::runIntrospection(const iox::units::Duration updatePeriodM
}
}


// process
SubscriberType processSubscriber(IntrospectionProcessService);
if (introspectionSelection.process == true)
Expand Down

0 comments on commit fed851f

Please sign in to comment.