Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
58090f7d
Commit
58090f7d
authored
Jun 01, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix heap-use-after-free issue in private_thread
parent
1a32df0c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
11 deletions
+24
-11
libcaf_core/src/local_actor.cpp
libcaf_core/src/local_actor.cpp
+24
-11
No files found.
libcaf_core/src/local_actor.cpp
View file @
58090f7d
...
...
@@ -42,7 +42,16 @@ namespace caf {
class
local_actor
::
private_thread
{
public:
private_thread
(
local_actor
*
self
)
:
self_destroyed_
(
false
),
self_
(
self
)
{
enum
worker_state
{
active
,
shutdown_requested
,
await_resume_or_shutdown
};
private_thread
(
local_actor
*
self
)
:
self_destroyed_
(
false
),
self_
(
self
),
state_
(
active
)
{
intrusive_ptr_add_ref
(
self
->
ctrl
());
scheduler
::
inc_detached_threads
();
}
...
...
@@ -54,11 +63,9 @@ public:
CAF_LOG_TRACE
(
""
);
scoped_execution_unit
ctx
{
&
job
->
system
()};
auto
max_throughput
=
std
::
numeric_limits
<
size_t
>::
max
();
auto
wait_pred
=
[
&
]
{
return
!
job
->
mailbox
().
empty
();
};
for
(;;)
{
bool
resume_later
;
for
(;;)
{
state_
=
await_resume_or_shutdown
;
do
{
resume_later
=
false
;
switch
(
job
->
resume
(
&
ctx
,
max_throughput
))
{
...
...
@@ -76,22 +83,27 @@ public:
}
}
while
(
resume_later
);
// wait until actor becomes ready again or was destroyed
std
::
unique_lock
<
std
::
mutex
>
guard
(
mtx_
);
cv_
.
wait
(
guard
,
wait_pred
);
job
=
const_cast
<
local_actor
*>
(
self_
);
if
(
!
job
)
if
(
!
await_resume
())
return
;
}
}
bool
await_resume
()
{
std
::
unique_lock
<
std
::
mutex
>
guard
(
mtx_
);
while
(
state_
==
await_resume_or_shutdown
)
cv_
.
wait
(
guard
);
return
state_
==
active
;
}
void
resume
()
{
std
::
unique_lock
<
std
::
mutex
>
guard
(
mtx_
);
state_
=
active
;
cv_
.
notify_one
();
}
void
shutdown
()
{
std
::
unique_lock
<
std
::
mutex
>
guard
(
mtx_
);
s
elf_
=
nullptr
;
s
tate_
=
shutdown_requested
;
cv_
.
notify_one
();
}
...
...
@@ -121,10 +133,11 @@ public:
}
private:
volatile
bool
self_destroyed_
;
std
::
mutex
mtx_
;
std
::
condition_variable
cv_
;
volatile
bool
self_destroyed_
;
volatile
local_actor
*
self_
;
volatile
worker_state
state_
;
};
result
<
message
>
reflect
(
local_actor
*
,
const
type_erased_tuple
*
x
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment