Skip to content

Commit

Permalink
runtime: Mark runtime_goexit function as noinline.
Browse files Browse the repository at this point in the history
If the compiler inlines this function into kickoff, it may reuse
the TLS block address to load g. However, this is not necessarily
correct, as the call to g->entry in kickoff may cause the TLS
address to change. If the wrong value is loaded for g->status in
runtime_goexit, it may cause a runtime panic.

By marking the function as noinline we prevent the compiler from
reusing the TLS address.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215484 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
ian committed Sep 22, 2014
1 parent 47d6df0 commit c459ce0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions libgo/runtime/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,7 @@ runtime_gosched0(G *gp)
// Need to mark it as nosplit, because it runs with sp > stackbase (as runtime_lessstack).
// Since it does not return it does not matter. But if it is preempted
// at the split stack check, GC will complain about inconsistent sp.
void runtime_goexit(void) __attribute__ ((noinline));
void
runtime_goexit(void)
{
Expand Down

0 comments on commit c459ce0

Please sign in to comment.