Skip to content

Commit

Permalink
Avoid division in round_up.
Browse files Browse the repository at this point in the history
Division may require a function call, leading to
dynamic function lookup, leading to deadlock in rtld.

Pull Request:	#1343
  • Loading branch information
VoxSciurorum authored and brooksdavis committed Jul 25, 2024
1 parent feda329 commit 2b22973
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/libthr/thread/thr_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ static char *last_stack = NULL;
static inline size_t
round_up(size_t size)
{
if (size % _thr_page_size != 0)
size = ((size / _thr_page_size) + 1) *
_thr_page_size;
return size;
return (roundup2(size, _thr_page_size - 1));
}

void
Expand Down

0 comments on commit 2b22973

Please sign in to comment.