mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-30 11:07:29 +09:00
[js] Error-check pthread calls
These calls return error states (int) that weren't checked for success. Failures here are fatal, so using MOZ_RELEASE_ASSERT to safely crash.
This commit is contained in:
parent
7cadc57d49
commit
425f38ff84
1 changed files with 9 additions and 10 deletions
|
|
@ -107,15 +107,14 @@ js::GetNativeStackBaseImpl()
|
||||||
pthread_t thread = pthread_self();
|
pthread_t thread = pthread_self();
|
||||||
pthread_attr_t sattr;
|
pthread_attr_t sattr;
|
||||||
pthread_attr_init(&sattr);
|
pthread_attr_init(&sattr);
|
||||||
pthread_getattr_np(thread, &sattr);
|
int rc = pthread_getattr_np(thread, &sattr);
|
||||||
|
MOZ_RELEASE_ASSERT(rc == 0, "Call to pthread_getattr_np failed.");
|
||||||
|
|
||||||
// stackBase will be the *lowest* address on all architectures.
|
// stackBase will be the *lowest* address on all architectures.
|
||||||
void* stackBase = nullptr;
|
void* stackBase = nullptr;
|
||||||
size_t stackSize = 0;
|
size_t stackSize = 0;
|
||||||
int rc = pthread_attr_getstack(&sattr, &stackBase, &stackSize);
|
rc = pthread_attr_getstack(&sattr, &stackBase, &stackSize);
|
||||||
if (rc) {
|
MOZ_RELEASE_ASSERT(rc == 0, "Call to pthread_attr_getstack failed, unable to setup stack range for JS.");
|
||||||
MOZ_CRASH("Call to pthread_attr_getstack failed, unable to setup stack range for JS.");
|
|
||||||
}
|
|
||||||
MOZ_RELEASE_ASSERT(stackBase, "Invalid stack base, unable to setup stack range for JS.");
|
MOZ_RELEASE_ASSERT(stackBase, "Invalid stack base, unable to setup stack range for JS.");
|
||||||
pthread_attr_destroy(&sattr);
|
pthread_attr_destroy(&sattr);
|
||||||
|
|
||||||
|
|
@ -131,6 +130,7 @@ js::GetNativeStackBaseImpl()
|
||||||
void*
|
void*
|
||||||
js::GetNativeStackBaseImpl()
|
js::GetNativeStackBaseImpl()
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
pthread_t thread = pthread_self();
|
pthread_t thread = pthread_self();
|
||||||
# if defined(XP_DARWIN) || defined(DARWIN)
|
# if defined(XP_DARWIN) || defined(DARWIN)
|
||||||
return pthread_get_stackaddr_np(thread);
|
return pthread_get_stackaddr_np(thread);
|
||||||
|
|
@ -148,14 +148,15 @@ js::GetNativeStackBaseImpl()
|
||||||
* FIXME: this function is non-portable;
|
* FIXME: this function is non-portable;
|
||||||
* other POSIX systems may have different np alternatives
|
* other POSIX systems may have different np alternatives
|
||||||
*/
|
*/
|
||||||
pthread_getattr_np(thread, &sattr);
|
rc = pthread_getattr_np(thread, &sattr);
|
||||||
|
MOZ_RELEASE_ASSERT(rc == 0, "Call to pthread_getattr_np failed.");
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
void* stackBase = 0;
|
void* stackBase = 0;
|
||||||
size_t stackSize = 0;
|
size_t stackSize = 0;
|
||||||
int rc;
|
|
||||||
# if defined(__OpenBSD__)
|
# if defined(__OpenBSD__)
|
||||||
rc = pthread_stackseg_np(pthread_self(), &ss);
|
rc = pthread_stackseg_np(pthread_self(), &ss);
|
||||||
|
MOZ_RELEASE_ASSERT(rc == 0, "Call to pthread_stackseg_np failed, unable to setup stack range for JS.");
|
||||||
stackBase = (void*)((size_t) ss.ss_sp - ss.ss_size);
|
stackBase = (void*)((size_t) ss.ss_sp - ss.ss_size);
|
||||||
stackSize = ss.ss_size;
|
stackSize = ss.ss_size;
|
||||||
# elif defined(ANDROID)
|
# elif defined(ANDROID)
|
||||||
|
|
@ -198,10 +199,8 @@ js::GetNativeStackBaseImpl()
|
||||||
// differs between libc implementations and could imply /proc access etc.
|
// differs between libc implementations and could imply /proc access etc.
|
||||||
// which may not work in restricted environments.
|
// which may not work in restricted environments.
|
||||||
rc = pthread_attr_getstack(&sattr, &stackBase, &stackSize);
|
rc = pthread_attr_getstack(&sattr, &stackBase, &stackSize);
|
||||||
|
MOZ_RELEASE_ASSERT(rc == 0, "Call to pthread_attr_getstack failed, unable to setup stack range for JS.");
|
||||||
# endif
|
# endif
|
||||||
if (rc) {
|
|
||||||
MOZ_CRASH("Call to pthread_attr_getstack failed, unable to setup stack range for JS.");
|
|
||||||
}
|
|
||||||
MOZ_RELEASE_ASSERT(stackBase, "Invalid stack base, unable to setup stack range for JS.");
|
MOZ_RELEASE_ASSERT(stackBase, "Invalid stack base, unable to setup stack range for JS.");
|
||||||
pthread_attr_destroy(&sattr);
|
pthread_attr_destroy(&sattr);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue