code
Mar 18, 2026EVAL-20260318-161503This distributed lock implementation has a subtle race condition that can cause two processes to hold the lock simultaneously. Find the bug and fix it. ```python import redis import time import uuid class DistributedLock: def __init__(self, redis_client, lock_name, timeout=10): self.redis = redis_client self.lock_name = f"lock:{lock_name}" self.timeout = timeout self.token = str(uuid.uuid4()) def acquire(self): while True: if self.redis.setnx(self.lock_name, self.token): self.redis.expire(self.lock_name, self.timeout) return True time.sleep(0.1) def release(self): if self.redis.get(self.lock_name) == self.token: self.redis.delete(self.lock_name) ``` Explain why this is dangerous in production and provide a correct implementation.
Winner
GPT-5.4
openrouter
9.97
WINNER SCORE
matrix avg: 8.22
10×10 Judgment Matrix · 42 judgments
OPEN DATA
| Judge ↓ / Respondent → | MiniMax M2.7 | MiniMax M2.5 | MiniMax M2.1 | MiniMax M2 | MiniMax M1 | MiniMax-01 | Claude Sonnet 4.6 | GPT-5.4 |
|---|---|---|---|---|---|---|---|---|
| MiniMax M2.7 | — | 9.4 | · | · | 10.0 | 8.8 | 10.0 | 10.0 |
| MiniMax M2.5 | 9.3 | — | · | · | 9.4 | 8.6 | 9.8 | 10.0 |
| MiniMax M2.1 | 9.8 | · | — | · | 10.0 | 7.8 | 10.0 | 10.0 |
| MiniMax M2 | 9.8 | 9.0 | · | — | 10.0 | 8.3 | 10.0 | 10.0 |
| MiniMax M1 | 8.3 | 9.0 | · | · | — | 8.3 | 10.0 | 10.0 |
| MiniMax-01 | 10.0 | 9.6 | 1.9 | · | 9.8 | — | 10.0 | 9.8 |
| Claude Sonnet 4.6 | 9.6 | 9.0 | · | · | 9.6 | 8.6 | — | 10.0 |
| GPT-5.4 | 7.4 | 6.7 | · | · | 8.8 | 7.8 | 8.7 | — |