Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
47ba04ab
Commit
47ba04ab
authored
Jan 22, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid crash when M structure free just before thread exit.
From-SVN: r169121
parent
03986896
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
libgo/runtime/go-go.c
+7
-0
libgo/runtime/thread.c
+10
-6
No files found.
libgo/runtime/go-go.c
View file @
47ba04ab
...
@@ -94,6 +94,13 @@ remove_current_thread (void)
...
@@ -94,6 +94,13 @@ remove_current_thread (void)
runtime_MCache_ReleaseAll
(
mcache
);
runtime_MCache_ReleaseAll
(
mcache
);
/* As soon as we release this look, a GC could run. Since this
thread is no longer on the list, the GC will not find our M
structure, so it could get freed at any time. That means that
any code from here to thread exit must not assume that the m is
valid. */
m
=
NULL
;
i
=
pthread_mutex_unlock
(
&
__go_thread_ids_lock
);
i
=
pthread_mutex_unlock
(
&
__go_thread_ids_lock
);
__go_assert
(
i
==
0
);
__go_assert
(
i
==
0
);
...
...
libgo/runtime/thread.c
View file @
47ba04ab
...
@@ -38,9 +38,11 @@ runtime_lock_full(Lock *l)
...
@@ -38,9 +38,11 @@ runtime_lock_full(Lock *l)
void
void
runtime_lock
(
Lock
*
l
)
runtime_lock
(
Lock
*
l
)
{
{
if
(
m
->
locks
<
0
)
if
(
m
!=
nil
)
{
runtime_throw
(
"lock count"
);
if
(
m
->
locks
<
0
)
m
->
locks
++
;
runtime_throw
(
"lock count"
);
m
->
locks
++
;
}
if
(
runtime_xadd
(
&
l
->
key
,
1
)
>
1
)
// someone else has it; wait
if
(
runtime_xadd
(
&
l
->
key
,
1
)
>
1
)
// someone else has it; wait
runtime_lock_full
(
l
);
runtime_lock_full
(
l
);
...
@@ -58,9 +60,11 @@ runtime_unlock_full(Lock *l)
...
@@ -58,9 +60,11 @@ runtime_unlock_full(Lock *l)
void
void
runtime_unlock
(
Lock
*
l
)
runtime_unlock
(
Lock
*
l
)
{
{
m
->
locks
--
;
if
(
m
!=
nil
)
{
if
(
m
->
locks
<
0
)
m
->
locks
--
;
runtime_throw
(
"lock count"
);
if
(
m
->
locks
<
0
)
runtime_throw
(
"lock count"
);
}
if
(
runtime_xadd
(
&
l
->
key
,
-
1
)
>
0
)
// someone else is waiting
if
(
runtime_xadd
(
&
l
->
key
,
-
1
)
>
0
)
// someone else is waiting
runtime_unlock_full
(
l
);
runtime_unlock_full
(
l
);
...
...
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