Mercurial > hg > graal-jvmci-8
comparison src/os/windows/vm/os_windows.cpp @ 11151:5e3b6f79d280
8020701: Avoid crashes in WatcherThread
Reviewed-by: acorn, dcubed, dsimms
author | rbackman |
---|---|
date | Wed, 17 Jul 2013 13:48:15 +0200 |
parents | 59b052799158 |
children | af21010d1062 |
comparison
equal
deleted
inserted
replaced
11150:c29568b733d2 | 11151:5e3b6f79d280 |
---|---|
4682 jio_fprintf(stderr, | 4682 jio_fprintf(stderr, |
4683 "Could not open pause file '%s', continuing immediately.\n", filename); | 4683 "Could not open pause file '%s', continuing immediately.\n", filename); |
4684 } | 4684 } |
4685 } | 4685 } |
4686 | 4686 |
4687 os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() { | |
4688 assert(Thread::current()->is_Watcher_thread(), "Must be WatcherThread"); | |
4689 } | |
4690 | |
4691 /* | |
4692 * See the caveats for this class in os_windows.hpp | |
4693 * Protects the callback call so that raised OS EXCEPTIONS causes a jump back | |
4694 * into this method and returns false. If no OS EXCEPTION was raised, returns | |
4695 * true. | |
4696 * The callback is supposed to provide the method that should be protected. | |
4697 */ | |
4698 bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) { | |
4699 assert(Thread::current()->is_Watcher_thread(), "Only for WatcherThread"); | |
4700 assert(!WatcherThread::watcher_thread()->has_crash_protection(), | |
4701 "crash_protection already set?"); | |
4702 | |
4703 bool success = true; | |
4704 __try { | |
4705 WatcherThread::watcher_thread()->set_crash_protection(this); | |
4706 cb.call(); | |
4707 } __except(EXCEPTION_EXECUTE_HANDLER) { | |
4708 // only for protection, nothing to do | |
4709 success = false; | |
4710 } | |
4711 WatcherThread::watcher_thread()->set_crash_protection(NULL); | |
4712 return success; | |
4713 } | |
4714 | |
4687 // An Event wraps a win32 "CreateEvent" kernel handle. | 4715 // An Event wraps a win32 "CreateEvent" kernel handle. |
4688 // | 4716 // |
4689 // We have a number of choices regarding "CreateEvent" win32 handle leakage: | 4717 // We have a number of choices regarding "CreateEvent" win32 handle leakage: |
4690 // | 4718 // |
4691 // 1: When a thread dies return the Event to the EventFreeList, clear the ParkHandle | 4719 // 1: When a thread dies return the Event to the EventFreeList, clear the ParkHandle |