Skip to content

Commit

Permalink
Added support for Guru Mediation, and raising a guru mediation if ref…
Browse files Browse the repository at this point in the history
…Count <= 0 but decrRefCount is called against such an object
  • Loading branch information
antirez committed Apr 17, 2010
1 parent 55017f9 commit c651fd9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions redis.c
Expand Up @@ -237,7 +237,9 @@ static char* strencoding[] = {

/* We can print the stacktrace, so our assert is defined this way: */
#define redisAssert(_e) ((_e)?(void)0 : (_redisAssert(#_e,__FILE__,__LINE__),_exit(1)))
#define redisPanic(_e) _redisPanic(#_e,__FILE__,__LINE__),_exit(1)
static void _redisAssert(char *estr, char *file, int line);
static void _redisPanic(char *msg, char *file, int line);

/*================================= Data types ============================== */

Expand Down Expand Up @@ -2851,6 +2853,7 @@ static void incrRefCount(robj *o) {
static void decrRefCount(void *obj) {
robj *o = obj;

if (o->refcount <= 0) redisPanic("decrRefCount against refcount <= 0");
/* Object is a key of a swapped out value, or in the process of being
* loaded. */
if (server.vm_enabled &&
Expand Down Expand Up @@ -9859,6 +9862,15 @@ static void _redisAssert(char *estr, char *file, int line) {
#endif
}

static void _redisPanic(char *msg, char *file, int line) {
redisLog(REDIS_WARNING,"!!! Software Failure. Press left mouse button to continue");
redisLog(REDIS_WARNING,"Guru Mediation: %s #%s:%d",msg,file,line);

This comment has been minimized.

Copy link
@cmelbye

cmelbye Apr 17, 2010

Did you mean to say Guru Meditation?

#ifdef HAVE_BACKTRACE
redisLog(REDIS_WARNING,"(forcing SIGSEGV in order to print the stack trace)");
*((char*)-1) = 'x';
#endif
}

/* =================================== Main! ================================ */

#ifdef __linux__
Expand Down

4 comments on commit c651fd9

@gildo
Copy link

@gildo gildo commented on c651fd9 Apr 17, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

@superfeedr
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D

@chrisforbes
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure the original was "meditation"

@sebastien
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.