use serverAssert() instead of assert() to get callstacks in fastlock
Former-commit-id: 45535e8a6377963dce5b158a9a6e448c5c22a0a8
This commit is contained in:
parent
2a73085de9
commit
a1d9c2e827
@ -45,6 +45,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "config.h"
|
||||
#include "serverassert.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <TargetConditionals.h>
|
||||
@ -164,7 +165,7 @@ extern "C" pid_t gettid()
|
||||
if (pidCache == -1) {
|
||||
uint64_t tidT;
|
||||
pthread_threadid_np(nullptr, &tidT);
|
||||
assert(tidT < UINT_MAX);
|
||||
serverAssert(tidT < UINT_MAX);
|
||||
pidCache = (int)tidT;
|
||||
}
|
||||
#endif
|
||||
@ -393,7 +394,7 @@ extern "C" void fastlock_unlock(struct fastlock *lock)
|
||||
{
|
||||
int pidT;
|
||||
__atomic_load(&lock->m_pidOwner, &pidT, __ATOMIC_RELAXED);
|
||||
assert(pidT >= 0); // unlock after free
|
||||
serverAssert(pidT >= 0); // unlock after free
|
||||
int t = -1;
|
||||
__atomic_store(&lock->m_pidOwner, &t, __ATOMIC_RELEASE);
|
||||
std::atomic_thread_fence(std::memory_order_release);
|
||||
@ -431,7 +432,7 @@ extern "C" void unlock_futex(struct fastlock *lock, uint16_t ifutex)
|
||||
extern "C" void fastlock_free(struct fastlock *lock)
|
||||
{
|
||||
// NOP
|
||||
assert((lock->m_ticket.m_active == lock->m_ticket.m_avail) // Asser the lock is unlocked
|
||||
serverAssert((lock->m_ticket.m_active == lock->m_ticket.m_avail) // Asser the lock is unlocked
|
||||
|| (lock->m_pidOwner == gettid() && (lock->m_ticket.m_active == lock->m_ticket.m_avail-1))); // OR we own the lock and nobody else is waiting
|
||||
lock->m_pidOwner = -2; // sentinal value indicating free
|
||||
ANNOTATE_RWLOCK_DESTROY(lock);
|
||||
|
14
src/server.h
14
src/server.h
@ -92,6 +92,7 @@ typedef long long ustime_t; /* microsecond time type. */
|
||||
#include "uuid.h"
|
||||
#include "semiorderedset.h"
|
||||
#include "connection.h" /* Connection abstraction */
|
||||
#include "serverassert.h"
|
||||
|
||||
#define REDISMODULE_CORE 1
|
||||
#include "redismodule.h" /* Redis modules API defines. */
|
||||
@ -610,16 +611,6 @@ public:
|
||||
* The actual resolution depends on g_pserver->hz. */
|
||||
#define run_with_period(_ms_) if ((_ms_ <= 1000/g_pserver->hz) || !(g_pserver->cronloops%((_ms_)/(1000/g_pserver->hz))))
|
||||
|
||||
/* We can print the stacktrace, so our assert is defined this way: */
|
||||
#define serverAssertWithInfo(_c,_o,_e) ((_e)?(void)0 : (_serverAssertWithInfo(_c,_o,#_e,__FILE__,__LINE__),_exit(1)))
|
||||
#define serverAssert(_e) ((_e)?(void)0 : (_serverAssert(#_e,__FILE__,__LINE__),_exit(1)))
|
||||
#ifdef _DEBUG
|
||||
#define serverAssertDebug(_e) serverAssert(_e)
|
||||
#else
|
||||
#define serverAssertDebug(_e)
|
||||
#endif
|
||||
#define serverPanic(...) _serverPanic(__FILE__,__LINE__,__VA_ARGS__),_exit(1)
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Data types
|
||||
*----------------------------------------------------------------------------*/
|
||||
@ -2996,9 +2987,6 @@ void *realloc(void *ptr, size_t size);
|
||||
#endif
|
||||
|
||||
/* Debugging stuff */
|
||||
void _serverAssertWithInfo(const client *c, robj_roptr o, const char *estr, const char *file, int line);
|
||||
extern "C" void _serverAssert(const char *estr, const char *file, int line);
|
||||
extern "C" void _serverPanic(const char *file, int line, const char *msg, ...);
|
||||
void bugReportStart(void);
|
||||
void serverLogObjectDebugInfo(robj_roptr o);
|
||||
void sigsegvHandler(int sig, siginfo_t *info, void *secret);
|
||||
|
15
src/serverassert.h
Normal file
15
src/serverassert.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
void _serverAssertWithInfo(const struct client *c, class robj_roptr o, const char *estr, const char *file, int line);
|
||||
extern "C" void _serverAssert(const char *estr, const char *file, int line);
|
||||
extern "C" void _serverPanic(const char *file, int line, const char *msg, ...);
|
||||
|
||||
/* We can print the stacktrace, so our assert is defined this way: */
|
||||
#define serverAssertWithInfo(_c,_o,_e) ((_e)?(void)0 : (_serverAssertWithInfo(_c,_o,#_e,__FILE__,__LINE__),_exit(1)))
|
||||
#define serverAssert(_e) ((_e)?(void)0 : (_serverAssert(#_e,__FILE__,__LINE__),_exit(1)))
|
||||
#ifdef _DEBUG
|
||||
#define serverAssertDebug(_e) serverAssert(_e)
|
||||
#else
|
||||
#define serverAssertDebug(_e)
|
||||
#endif
|
||||
#define serverPanic(...) _serverPanic(__FILE__,__LINE__,__VA_ARGS__),_exit(1)
|
Loading…
x
Reference in New Issue
Block a user