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

Detect use-after-free of hrpExecutionContext #1208

Merged
merged 2 commits into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ec/hrpEC/hrpEC-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ namespace RTC
{
hrpExecutionContext::~hrpExecutionContext()
{
if (m_thread_pending)
abort ();
}
int hrpExecutionContext::svc(void)
{
int ret = svc_wrapped ();
m_thread_pending = false;
return ret;
}
int hrpExecutionContext::svc_wrapped(void)
{
if (open_iob() == FALSE){
std::cerr << "open_iob: failed to open" << std::endl;
Expand Down Expand Up @@ -191,6 +199,12 @@ namespace RTC
throw OpenHRP::ExecutionProfileService::ExecutionProfileServiceException("no such component");
}

void hrpExecutionContext::activate ()
{
m_thread_pending = true;
PeriodicExecutionContext::activate ();
}

void hrpExecutionContext::resetProfile()
{
m_profile.max_period = m_profile.avg_period = 0;
Expand Down
3 changes: 2 additions & 1 deletion ec/hrpEC/hrpEC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ namespace RTC
#else
: RTC_exp::PeriodicExecutionContext(),
#endif
m_priority(49)
m_priority(49),
m_thread_pending (false)
{
resetProfile();
rtclog.setName("hrpEC");
Expand Down
4 changes: 4 additions & 0 deletions ec/hrpEC/hrpEC.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace RTC
#ifdef OPENRTM_VERSION_TRUNK
virtual void tick(){}
#endif
void activate ();

OpenHRP::ExecutionProfileService::Profile *getProfile();
OpenHRP::ExecutionProfileService::ComponentProfile getComponentProfile(RTC::LightweightRTObject_ptr obj);
Expand Down Expand Up @@ -64,10 +65,13 @@ namespace RTC
}
fprintf(stderr, "[ms]\n");
};
int svc_wrapped (void);

OpenHRP::ExecutionProfileService::Profile m_profile;
struct timeval m_tv;
int m_priority;
std::vector<std::string> rtc_names;
volatile bool m_thread_pending;
};
};

Expand Down