Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Bug 6376: core.thread.thread_scanAll doesn't scan the stack due to ASLR #43

Merged
merged 2 commits into from
Aug 2, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions src/core/sys/posix/pthread.d
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,22 @@ int pthread_mutexattr_getprotocol(in pthread_mutexattr_t*, int*); (TPI|TPP)
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int); (TPP)
int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int); (TPI|TPP)
*/
version( OSX )
{
enum
{
PTHREAD_PRIO_NONE,
PTHREAD_PRIO_INHERIT,
PTHREAD_PRIO_PROTECT
}

int pthread_mutex_getprioceiling(in pthread_mutex_t*, int*);
int pthread_mutex_setprioceiling(pthread_mutex_t*, int, int*);
int pthread_mutexattr_getprioceiling(in pthread_mutexattr_t*, int*);
int pthread_mutexattr_getprotocol(in pthread_mutexattr_t*, int*);
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int);
int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int);
}

//
// Scheduling (TPS)
Expand Down Expand Up @@ -697,4 +713,69 @@ version( FreeBSD )
int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
}
else version( OSX )
{
int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
int pthread_condattr_setpshared(pthread_condattr_t*, int);
int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
}

//
// Non-POSIX OS-Specific Additions
//

version( OSX )
{
import core.sys.osx.mach.port;

// returns non-zero if pthread_create or cthread_fork have been called
int pthread_is_threaded_np();

int pthread_threadid_np(pthread_t, ulong*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)

int pthread_rwlock_longrdlock_np(pthread_rwlock_t*);
int pthread_rwlock_yieldwrlock_np(pthread_rwlock_t*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
int pthread_rwlock_downgrade_np(pthread_rwlock_t*);
int pthread_rwlock_upgrade_np(pthread_rwlock_t*);
int pthread_rwlock_tryupgrade_np(pthread_rwlock_t*);
int pthread_rwlock_held_np(pthread_rwlock_t*);
int pthread_rwlock_rdheld_np(pthread_rwlock_t*);
int pthread_rwlock_wrheld_np(pthread_rwlock_t*);

// SPI to set and get pthread name
int pthread_getname_np(pthread_t, char*, size_t);
int pthread_setname_np(in char*);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)

// returns non-zero if the current thread is the main thread
int pthread_main_np();

// return the mach thread bound to the pthread
mach_port_t pthread_mach_thread_np(pthread_t);
size_t pthread_get_stacksize_np(pthread_t);
void* pthread_get_stackaddr_np(pthread_t);

// Like pthread_cond_signal(), but only wake up the specified pthread
int pthread_cond_signal_thread_np(pthread_cond_t*, pthread_t);

// Like pthread_cond_timedwait, but use a relative timeout
int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, in timespec*);

// Like pthread_create(), but leaves the thread suspended
int pthread_create_suspended_np(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
int pthread_kill(pthread_t, int);

pthread_t pthread_from_mach_thread_np(mach_port_t);
// ^ __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)

int pthread_sigmask(int, in sigset_t*, sigset_t*);
// ^ __DARWIN_ALIAS(pthread_sigmask)

void pthread_yield_np();
}

6 changes: 5 additions & 1 deletion src/rt/memory.d
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ private
extern (C) extern __gshared void* __libc_stack_end;
}
}
version( OSX )
{
import core.sys.posix.pthread;
}
extern (C) void gc_addRange( void* p, size_t sz );
extern (C) void gc_removeRange( void* p );
}
Expand Down Expand Up @@ -100,7 +104,7 @@ extern (C) void* rt_stackBottom()
}
else version( OSX )
{
return cast(void*) 0xc0000000;
return pthread_get_stackaddr_np(pthread_self());
}
else version( FreeBSD )
{
Expand Down