comparison src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp @ 4006:436b4a3231bf

7098194: integrate macosx-port changes Summary: Integrate bsd-port/hotspot and macosx-port/hotspot changes as of 2011.09.29. Reviewed-by: kvn, dholmes, never, phh Contributed-by: Christos Zoulas <christos@zoulas.com>, Greg Lewis <glewis@eyesbeyond.com>, Kurt Miller <kurt@intricatesoftware.com>, Alexander Strange <astrange@apple.com>, Mike Swingler <swingler@apple.com>, Roger Hoover <rhoover@apple.com>, Victor Hernandez <vhernandez@apple.com>, Pratik Solanki <psolanki@apple.com>
author dcubed
date Thu, 13 Oct 2011 09:35:42 -0700
parents f08d439fab8c
children da4be62fb889
comparison
equal deleted inserted replaced
4005:2ef3386478e6 4006:436b4a3231bf
167 } 167 }
168 } 168 }
169 169
170 if (info != NULL && thread != NULL) { 170 if (info != NULL && thread != NULL) {
171 // Handle ALL stack overflow variations here 171 // Handle ALL stack overflow variations here
172 if (sig == SIGSEGV) { 172 if (sig == SIGSEGV || sig == SIGBUS) {
173 address addr = (address) info->si_addr; 173 address addr = (address) info->si_addr;
174 174
175 // check if fault address is within thread stack 175 // check if fault address is within thread stack
176 if (addr < thread->stack_base() && 176 if (addr < thread->stack_base() &&
177 addr >= thread->stack_base() - thread->stack_size()) { 177 addr >= thread->stack_base() - thread->stack_size()) {
226 226
227 // Check to see if we caught the safepoint code in the process 227 // Check to see if we caught the safepoint code in the process
228 // of write protecting the memory serialization page. It write 228 // of write protecting the memory serialization page. It write
229 // enables the page immediately after protecting it so we can 229 // enables the page immediately after protecting it so we can
230 // just return to retry the write. 230 // just return to retry the write.
231 if (sig == SIGSEGV && 231 if ((sig == SIGSEGV || sig == SIGBUS) &&
232 os::is_memory_serialize_page(thread, (address) info->si_addr)) { 232 os::is_memory_serialize_page(thread, (address) info->si_addr)) {
233 // Block current thread until permission is restored. 233 // Block current thread until permission is restored.
234 os::block_on_serialize_page_trap(); 234 os::block_on_serialize_page_trap();
235 return true; 235 return true;
236 } 236 }
258 "\n# | | =-*-=__\\ " 258 "\n# | | =-*-=__\\ "
259 "\n# OOO c_c_(___)"); 259 "\n# OOO c_c_(___)");
260 } 260 }
261 #endif // !PRODUCT 261 #endif // !PRODUCT
262 262
263 const char *fmt = "caught unhandled signal %d"; 263 const char *fmt =
264 char buf[64]; 264 "caught unhandled signal " INT32_FORMAT " at address " PTR_FORMAT;
265 265 char buf[128];
266 sprintf(buf, fmt, sig); 266
267 sprintf(buf, fmt, sig, info->si_addr);
267 fatal(buf); 268 fatal(buf);
268 } 269 }
269 270
270 void os::Bsd::init_thread_fpu_state(void) { 271 void os::Bsd::init_thread_fpu_state(void) {
271 // Nothing to do 272 // Nothing to do
336 #elif defined(__OpenBSD__) 337 #elif defined(__OpenBSD__)
337 stack_t ss; 338 stack_t ss;
338 int rslt = pthread_stackseg_np(pthread_self(), &ss); 339 int rslt = pthread_stackseg_np(pthread_self(), &ss);
339 340
340 if (rslt != 0) 341 if (rslt != 0)
341 fatal(err_msg("pthread_stackseg_np failed with err = %d", rslt)); 342 fatal(err_msg("pthread_stackseg_np failed with err = " INT32_FORMAT,
343 rslt));
342 344
343 stack_top = (address) ss.ss_sp; 345 stack_top = (address) ss.ss_sp;
344 stack_bytes = ss.ss_size; 346 stack_bytes = ss.ss_size;
345 stack_bottom = stack_top - stack_bytes; 347 stack_bottom = stack_top - stack_bytes;
346 #elif defined(_ALLBSD_SOURCE) 348 #elif defined(_ALLBSD_SOURCE)
348 350
349 int rslt = pthread_attr_init(&attr); 351 int rslt = pthread_attr_init(&attr);
350 352
351 // JVM needs to know exact stack location, abort if it fails 353 // JVM needs to know exact stack location, abort if it fails
352 if (rslt != 0) 354 if (rslt != 0)
353 fatal(err_msg("pthread_attr_init failed with err = %d", rslt)); 355 fatal(err_msg("pthread_attr_init failed with err = " INT32_FORMAT, rslt));
354 356
355 rslt = pthread_attr_get_np(pthread_self(), &attr); 357 rslt = pthread_attr_get_np(pthread_self(), &attr);
356 358
357 if (rslt != 0) 359 if (rslt != 0)
358 fatal(err_msg("pthread_attr_get_np failed with err = %d", rslt)); 360 fatal(err_msg("pthread_attr_get_np failed with err = " INT32_FORMAT,
361 rslt));
359 362
360 if (pthread_attr_getstackaddr(&attr, (void **) &stack_bottom) != 0 || 363 if (pthread_attr_getstackaddr(&attr, (void **) &stack_bottom) != 0 ||
361 pthread_attr_getstacksize(&attr, &stack_bytes) != 0) { 364 pthread_attr_getstacksize(&attr, &stack_bytes) != 0) {
362 fatal("Can not locate current stack attributes!"); 365 fatal("Can not locate current stack attributes!");
363 } 366 }
371 if (res != 0) { 374 if (res != 0) {
372 if (res == ENOMEM) { 375 if (res == ENOMEM) {
373 vm_exit_out_of_memory(0, "pthread_getattr_np"); 376 vm_exit_out_of_memory(0, "pthread_getattr_np");
374 } 377 }
375 else { 378 else {
376 fatal(err_msg("pthread_getattr_np failed with errno = %d", res)); 379 fatal(err_msg("pthread_getattr_np failed with errno = " INT32_FORMAT,
380 res));
377 } 381 }
378 } 382 }
379 383
380 res = pthread_attr_getstack(&attr, (void **) &stack_bottom, &stack_bytes); 384 res = pthread_attr_getstack(&attr, (void **) &stack_bottom, &stack_bytes);
381 if (res != 0) { 385 if (res != 0) {
382 fatal(err_msg("pthread_attr_getstack failed with errno = %d", res)); 386 fatal(err_msg("pthread_attr_getstack failed with errno = " INT32_FORMAT,
387 res));
383 } 388 }
384 stack_top = stack_bottom + stack_bytes; 389 stack_top = stack_bottom + stack_bytes;
385 390
386 // The block of memory returned by pthread_attr_getstack() includes 391 // The block of memory returned by pthread_attr_getstack() includes
387 // guard pages where present. We need to trim these off. 392 // guard pages where present. We need to trim these off.
389 assert(((intptr_t) stack_bottom & (page_bytes - 1)) == 0, "unaligned stack"); 394 assert(((intptr_t) stack_bottom & (page_bytes - 1)) == 0, "unaligned stack");
390 395
391 size_t guard_bytes; 396 size_t guard_bytes;
392 res = pthread_attr_getguardsize(&attr, &guard_bytes); 397 res = pthread_attr_getguardsize(&attr, &guard_bytes);
393 if (res != 0) { 398 if (res != 0) {
394 fatal(err_msg("pthread_attr_getguardsize failed with errno = %d", res)); 399 fatal(err_msg(
400 "pthread_attr_getguardsize failed with errno = " INT32_FORMAT, res));
395 } 401 }
396 int guard_pages = align_size_up(guard_bytes, page_bytes) / page_bytes; 402 int guard_pages = align_size_up(guard_bytes, page_bytes) / page_bytes;
397 assert(guard_bytes == guard_pages * page_bytes, "unaligned guard"); 403 assert(guard_bytes == guard_pages * page_bytes, "unaligned guard");
398 404
399 #ifdef IA64 405 #ifdef IA64