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

8273373: Zero: Cannot invoke JVM in primordial threads on Zero #141

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/hotspot/os/linux/os_linux.cpp
Expand Up @@ -3354,6 +3354,9 @@ bool os::pd_create_stack_guard_pages(char* addr, size_t size) {

if (mincore((address)stack_extent, os::vm_page_size(), vec) == -1) {
// Fallback to slow path on all errors, including EAGAIN
assert((uintptr_t)addr >= stack_extent,
"Sanity: addr should be larger than extent, " PTR_FORMAT " >= " PTR_FORMAT,
p2i(addr), stack_extent);
stack_extent = (uintptr_t) get_stack_commited_bottom(
os::Linux::initial_thread_stack_bottom(),
(size_t)addr - stack_extent);
Expand Down
26 changes: 14 additions & 12 deletions src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp
Expand Up @@ -199,6 +199,20 @@ size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
}

static void current_stack_region(address *bottom, size_t *size) {
if (os::is_primordial_thread()) {
// primordial thread needs special handling because pthread_getattr_np()
// may return bogus value.
address stack_bottom = os::Linux::initial_thread_stack_bottom();
size_t stack_bytes = os::Linux::initial_thread_stack_size();

assert(os::current_stack_pointer() >= stack_bottom, "should do");
assert(os::current_stack_pointer() < stack_bottom + stack_bytes, "should do");

*bottom = stack_bottom;
*size = stack_bytes;
return;
}

pthread_attr_t attr;
int res = pthread_getattr_np(pthread_self(), &attr);
if (res != 0) {
Expand Down Expand Up @@ -247,18 +261,6 @@ static void current_stack_region(address *bottom, size_t *size) {

pthread_attr_destroy(&attr);

// The initial thread has a growable stack, and the size reported
// by pthread_attr_getstack is the maximum size it could possibly
// be given what currently mapped. This can be huge, so we cap it.
if (os::is_primordial_thread()) {
stack_bytes = stack_top - stack_bottom;

if (stack_bytes > JavaThread::stack_size_at_create())
stack_bytes = JavaThread::stack_size_at_create();

stack_bottom = stack_top - stack_bytes;
}

assert(os::current_stack_pointer() >= stack_bottom, "should do");
assert(os::current_stack_pointer() < stack_top, "should do");

Expand Down