[redis]github-348 Report

https://github.com/antirez/redis/issues/348

1. Symptom

When Redis 2.4 tries to load an RDB file (checkpoint file) from 1.2, it crashes.

1.1 Severity

Severe

1.2 Was there exception thrown?

Yes, crash

1.2.1 Were there multiple exceptions?

Yes. Redis stop + crash

1.3 Scope of the failure

Severe!

2. How to reproduce this failure

2.0 Version

2.4.7

2.1 Configuration

Standard

2.2 Reproduction procedure

1. use 1.2.2 to generate an RDB file to have an empty sorted set

2. shutdown (disconnect)

3. upgrade to 2.4.7 (config change)

4. start node (add node)

2.2.1 Timing order

In this order.

2.2.2 Events order externally controllable?

Yes

2.3 Can the logs tell how to reproduce the failure?

Yes.

2.4 How many machines needed?

1

3. Diagnosis procedure

3.1 Detailed Symptom (where you start)

You have the crash, and from the crash you can locate:

   redisAssert(p != NULL);

3.2 Backward inference

Not too much inference needed: the root cause is here!

3.3 Are the printed log sufficient for diagnosis?

Yes

4. Root cause

Instead of reject it, it should have simply returned 0.

4.1 Category:

Incorrect error handling (handled) --- statement coverage.

5. Fix

5.1 How?

https://github.com/antirez/redis/commit/feb282883b171c7bba13551f82c7049d36d81ead

@@ -502,7 +502,7 @@ int zzlIsInRange(unsigned char *zl, zrangespec *range) {

         return 0;

 

     p = ziplistIndex(zl,-1); /* Last score. */

-    redisAssert(p != NULL);

+    if (p == NULL) return 0; /* Empty sorted set */

     score = zzlGetScore(p);

     if (!zslValueGteMin(score,range))

         return 0;