mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 10:48:29 +00:00
Make some minor fixups to bug reporting, etc.
This commit is contained in:
parent
84764ce7b8
commit
3f015b1e51
31 changed files with 244 additions and 134 deletions
|
@ -195,7 +195,8 @@ static uint64_t __asan_roundup2pow(uint64_t x) {
|
|||
static char *__asan_utf8cpy(char *p, unsigned c) {
|
||||
uint64_t z;
|
||||
z = tpenc(c);
|
||||
do *p++ = z;
|
||||
do
|
||||
*p++ = z;
|
||||
while ((z >>= 8));
|
||||
return p;
|
||||
}
|
||||
|
@ -946,7 +947,8 @@ static void __asan_trace(struct AsanTrace *bt, const struct StackFrame *bp) {
|
|||
if (!__asan_checka(SHADOW(bp), sizeof(*bp) >> 3).kind) {
|
||||
addr = bp->addr;
|
||||
if (addr == weakaddr("__gc") && weakaddr("__gc")) {
|
||||
do --gi;
|
||||
do
|
||||
--gi;
|
||||
while ((addr = garbage->p[gi].ret) == weakaddr("__gc"));
|
||||
}
|
||||
bt->p[i] = addr;
|
||||
|
@ -1197,7 +1199,7 @@ void __asan_stack_free(char *p, size_t size, int classid) {
|
|||
}
|
||||
|
||||
void __asan_handle_no_return(void) {
|
||||
__asan_unpoison(GetStackAddr(0), GetStackSize());
|
||||
__asan_unpoison((void *)GetStackAddr(), GetStackSize());
|
||||
}
|
||||
|
||||
void __asan_register_globals(struct AsanGlobal g[], int n) {
|
||||
|
@ -1379,8 +1381,8 @@ static textstartup void __asan_shadow_mapping(struct MemoryIntervals *m,
|
|||
|
||||
static textstartup void __asan_shadow_existing_mappings(void) {
|
||||
__asan_shadow_mapping(&_mmi, 0);
|
||||
__asan_map_shadow((intptr_t)GetStackAddr(0), GetStackSize());
|
||||
__asan_poison(GetStackAddr(0), PAGESIZE, kAsanStackOverflow);
|
||||
__asan_map_shadow(GetStackAddr(), GetStackSize());
|
||||
__asan_poison((void *)GetStackAddr(), PAGESIZE, kAsanStackOverflow);
|
||||
}
|
||||
|
||||
textstartup void __asan_init(int argc, char **argv, char **envp,
|
||||
|
|
|
@ -79,6 +79,8 @@ o/$(MODE)/libc/intrin/futex_wake.o \
|
|||
o/$(MODE)/libc/intrin/gettid.greg.o \
|
||||
o/$(MODE)/libc/intrin/sys_gettid.greg.o \
|
||||
o/$(MODE)/libc/intrin/pthread_mutex_lock.o \
|
||||
o/$(MODE)/libc/intrin/pthread_mutex_wait.o \
|
||||
o/$(MODE)/libc/intrin/pthread_mutex_wake.o \
|
||||
o/$(MODE)/libc/intrin/pthread_mutex_unlock.o \
|
||||
o/$(MODE)/libc/intrin/pthread_mutex_trylock.o \
|
||||
o/$(MODE)/libc/intrin/_trylock_debug_4.o \
|
||||
|
@ -108,7 +110,6 @@ o/$(MODE)/libc/intrin/describeprotflags.o: \
|
|||
OVERRIDE_CFLAGS += \
|
||||
-fno-sanitize=address
|
||||
|
||||
o/$(MODE)/libc/intrin/exit.greg.o \
|
||||
o/$(MODE)/libc/intrin/exit1.greg.o \
|
||||
o/$(MODE)/libc/intrin/getenv.greg.o \
|
||||
o/$(MODE)/libc/intrin/wsarecv.o \
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "libc/limits.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/gettls.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/nexgen32e/threaded.h"
|
||||
#include "libc/nexgen32e/uart.internal.h"
|
||||
|
@ -154,6 +155,7 @@ privileged bool kisdangerous(const void *p) {
|
|||
|
||||
privileged static void klog(const char *b, size_t n) {
|
||||
int e;
|
||||
bool cf;
|
||||
size_t i;
|
||||
uint16_t dx;
|
||||
uint32_t wrote;
|
||||
|
@ -309,19 +311,15 @@ privileged static size_t kformat(char *b, size_t n, const char *fmt,
|
|||
|
||||
case 'P':
|
||||
if (!__vforked) {
|
||||
if (!__threaded) {
|
||||
if (!__tls_enabled) {
|
||||
x = __pid;
|
||||
} else {
|
||||
// clone() is linked and it yoinks gettid()
|
||||
x = weaken(gettid)();
|
||||
x = *(int *)(__get_tls_inline() + 0x38);
|
||||
}
|
||||
} else {
|
||||
asm volatile("syscall"
|
||||
: "=a"(x)
|
||||
: "0"(__NR_getpid)
|
||||
: "rcx", "rdx", "r11", "memory", "cc");
|
||||
x = 666;
|
||||
}
|
||||
goto FormatUnsigned;
|
||||
goto FormatDecimal;
|
||||
|
||||
case 'u':
|
||||
case 'd':
|
||||
|
@ -397,7 +395,8 @@ privileged static size_t kformat(char *b, size_t n, const char *fmt,
|
|||
i = 0;
|
||||
m = (1 << base) - 1;
|
||||
if (hash && x) sign = hash;
|
||||
do z[i++ & 127] = abet[x & m];
|
||||
do
|
||||
z[i++ & 127] = abet[x & m];
|
||||
while ((x >>= base) || (pdot && i < prec));
|
||||
goto EmitNumber;
|
||||
|
||||
|
@ -806,7 +805,7 @@ privileged void kvprintf(const char *fmt, va_list v) {
|
|||
* - `X` uppercase
|
||||
* - `T` timestamp
|
||||
* - `x` hexadecimal
|
||||
* - `P` pid (or tid if threaded)
|
||||
* - `P` PID (or TID if TLS is enabled)
|
||||
*
|
||||
* Types:
|
||||
*
|
||||
|
|
|
@ -119,6 +119,17 @@ void *pthread_getspecific(pthread_key_t);
|
|||
#define pthread_mutexattr_gettype(pAttr, pType) (*(pType) = (pAttr)->attr, 0)
|
||||
#define pthread_mutexattr_settype(pAttr, type) ((pAttr)->attr = type, 0)
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define pthread_mutex_init(mutex, pAttr) \
|
||||
({ \
|
||||
pthread_mutexattr_t *_pAttr = (pAttr); \
|
||||
*(mutex) = (pthread_mutex_t){ \
|
||||
(_pAttr) ? (_pAttr)->attr : PTHREAD_MUTEX_DEFAULT, \
|
||||
}; \
|
||||
0; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define pthread_mutex_lock(mutex) \
|
||||
(((mutex)->attr == PTHREAD_MUTEX_NORMAL && \
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
* @param attr may be NULL
|
||||
* @return 0 on success, or error number on failure
|
||||
*/
|
||||
int pthread_mutex_init(pthread_mutex_t *mutex,
|
||||
const pthread_mutexattr_t *attr) {
|
||||
int(pthread_mutex_init)(pthread_mutex_t *mutex,
|
||||
const pthread_mutexattr_t *attr) {
|
||||
bzero(mutex, sizeof(*mutex));
|
||||
mutex->attr = attr ? attr->attr : PTHREAD_MUTEX_DEFAULT;
|
||||
return 0;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/nt/console.h"
|
||||
#include "libc/nt/process.h"
|
||||
|
@ -34,10 +33,9 @@ const char kConsoleHandles[3] = {
|
|||
/**
|
||||
* Puts cmd.exe gui back the way it was.
|
||||
*/
|
||||
void __restorewintty(void) {
|
||||
noinstrument void __restorewintty(void) {
|
||||
int i;
|
||||
if (!IsWindows()) return;
|
||||
NTTRACE("__restorewintty()");
|
||||
if (GetCurrentProcessId() == __winmainpid) {
|
||||
for (i = 0; i < 3; ++i) {
|
||||
SetConsoleMode(GetStdHandle(kConsoleHandles[i]), __ntconsolemode[i]);
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
* Blocks until memory location becomes zero.
|
||||
*
|
||||
* This is intended to be used on the child thread id, which is updated
|
||||
* by the clone() system call when a thread terminates. The purpose of
|
||||
* this operation is to know when it's safe to munmap() a thread stack.
|
||||
* by the _spawn() system call when a thread terminates. The purpose of
|
||||
* this operation is to know when it's safe to munmap() a threads stack
|
||||
*/
|
||||
void _wait0(const int *ctid) {
|
||||
int x;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue