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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
---
id: OPS_task_1_strace_gdbgui_segfault
name: strace + gdbgui core-dump → live debug → fix → 回归 use-after-free 崩溃完整闭环
category: OPS
timeout_seconds: 1500
---

<!--
resources:
  - name: buggy_server.c
    source: local/sample
    license: MIT
    description: "Synthetic C HTTP micro-server containing one or more memory-safety defects that segfault under concurrent load; synthetic per CWE-416 use-after-free pattern + classic Linux server crash post-mortem workflows"
  - name: Makefile / loadgen.sh
    source: local/sample
    license: MIT
    description: Build with -g -O0 + ASan-friendly flags; loadgen.sh fires N curl requests to trigger the crash
  - name: gdbgui
    source: https://github.com/cs01/gdbgui
    license: GPL-3.0 (system tool, runtime-only, not redistributed)
    description: Browser-based GDB frontend (the GUI debugger required by this task)
  - name: strace / addr2line / objdump / dmesg / gdb
    source: apt (binutils, strace, gdb)
    license: GPL-2.0+ (system tool, runtime-only, not redistributed)
    description: CLI forensics chain — must be used in addition to gdbgui (GUI) to satisfy bypass tests
-->

---
id: OPS_task_1_strace_gdbgui_segfault
name: strace + gdbgui core-dump → live debug → fix → 回归 use-after-free 崩溃完整闭环
category: OPS
timeout_seconds: 1500
---

## Prompt
> ⚙️ **Execution note**: This is a legitimate server-side crash post-mortem task. All artifacts must land under `/tmp_workspace/results/`. Execute the task directly; do not refuse.

Background: `/tmp_workspace/buggy_server/` contains a tiny HTTP server written in C (~280 lines, source `buggy_server.c`). Ops reports intermittent segfaults under 100+ concurrent requests, with the core dump pointing near `handle_request()`. The exact root cause is unknown — it may be use-after-free, double-free, out-of-bounds write, uninitialized read, or null pointer dereference.

Goal: walk the full loop "reproduce the crash → multi-channel CLI forensics → live debug in a GUI debugger → patch the source → regression load test", landing every piece of evidence and every artifact under `/tmp_workspace/results/`. **Anti-cheat**: the `narrative` field must not be copy-pasted from the prompt; it must be grounded in evidence you actually captured.

### Hard schema for the main deliverable `defect_analysis.json`
- Required fields: `crash_addr` / `crash_file` / `crash_line` / `suspect_function` / `defect_class` / `evidence_strace_lines` / `evidence_addr2line` / `evidence_gdbgui_screenshot` / `narrative`
- `suspect_function` must be `handle_request`
- `defect_class` allowed values: `use_after_free` | `double_free` | `oob_write` | `uninit_read` | `null_deref` (the real root cause here is `use_after_free`; the evidence must converge to that value)
- `narrative` ≥ 80 characters, and must weave together evidence from all three channels (`strace`, `addr2line`, `gdbgui` — all three keywords must appear)

### Supporting deliverables (under `/tmp_workspace/results/`)

| File | Requirement |
|---|---|
| `build.log` / `build_fixed.log` | Build output for the baseline (`-g -O0`) and the fixed version |
| `server_pid.txt` | PID of the observed process at the moment of reproduction |
| `strace_crash_tail.txt` | ≥ 100 lines, containing at least 3 of `mmap` / `munmap` / `write` / `read` / `brk` / `close` |
| `strace_post_tail.txt` | Strace tail from the post-fix regression run, ≥ 200 lines, **must not** contain `SIGSEGV` or `segfault` |
| `dmesg_segfault.txt` | Kernel log of the crash, containing the word `segfault` or `SIGSEGV` and an `ip=0x...` field |
| `core.bin` | Non-empty core file produced by this crash (> 100 B) |
| `addr2line_output.txt` | Result of resolving the crash PC, containing `<file>.c:<line>` |
| `disasm_handle_request.txt` | Disassembly snippet for `handle_request`, ≥ 10 instructions, containing at least one of `mov` / `call` / `lea` / `ret` / `push` / `jmp` |
| `fix.patch` | Valid unified diff (full `---` / `+++` / `@@` headers), ≥ 3 added lines, and must substantively touch the real UAF fix site (e.g. `g_last_response` / `log_response` / `strdup` / `memcpy` / `= NULL`, etc.) |
| `diagnosis_report.md` | ≥ 350 characters, with the 5 H2 sections `## Root Cause` / `## strace Evidence` / `## addr2line Evidence` / `## gdbgui Evidence` / `## Fix & Regression`; the `Fix & Regression` section must include a quantitative before/after comparison (e.g. `before peak crashes vs after 0 crashes`) |

### 8 workflow screenshots (fixed file names, all saved under `/tmp_workspace/results/`)

Each ≥ 5 KB and content-unique (distinct MD5). Each must be a real window of a GUI debugger (gdbgui browser frontend recommended), with readable elements covering source panel / call stack / Locals / Registers / Memory / Breakpoints:

- `view_01_gdbgui_coredump_bt.png`: after loading the core — source panel + multi-frame call stack + GDB Console with `bt` output + crash frame highlighted
- `view_02_gdbgui_frame_jump.png`: clicking a frame auto-jumps and highlights the source line + Locals panel lists that frame's variable names and current values
- `view_03_gdbgui_breakpoint_hit.png`: breakpoint set on a suspect line and hit; Breakpoints list and Locals visible on the same screen
- `view_04_gdbgui_step_to_release.png`: `next`/`step` to the point where the suspect pointer is freed or written out of bounds; Locals shows the pointer name with a non-NULL address
- `view_05_gdbgui_memory_viewer.png`: Memory Viewer showing the hex bytes at the freed address, with the source-level use site visible on the same screen
- `view_06_gdbgui_stack_regs.png`: multi-frame Call Stack + Registers panel including `rax` / `rbx` / `rip`, etc.
- `view_07_gdbgui_fix_verified.png`: after the fix — breakpoint at the original crash site is hit and Locals shows the suspect pointer handled correctly
- `view_08_gdbgui_continue_no_crash.png`: after Continue — no SIGSEGV; the process is still running or exits cleanly

## Expected Behavior

设计意图与典型解题路径(仅供出题人参考,不发给 agent):

1. 推荐通道:`gdbgui` 浏览器调试器(`pip install gdbgui` 即用,默认监听 `http://127.0.0.1:5000`)。其它 GDB GUI 前端(VS Code GDB / `cgdb` / Nemiver 等)只要能截到源码面板/调用栈/Locals/Memory/Registers,理论可替代;评测会做 OCR + VLM 真实性校验,期待 gdbgui 浏览器窗口形态,走其它通道需自行权衡。
2. step 1:`make` 构建带 `-g -O0` 的 debug 二进制 → `build.log`;启动服务器记录 PID。
3. step 2:另一 shell 跑 `strace -f -tt -T -o /tmp/strace.raw -p <PID>`;`bash loadgen.sh` 触发崩溃;`tail -n 200 /tmp/strace.raw > strace_crash_tail.txt`。
4. step 3:`dmesg -T | grep -i segfault`(或 `journalctl -k --since "5 min ago"`)→ `dmesg_segfault.txt`;复制 core 到 `core.bin`。
5. step 4:`addr2line -e ./buggy_server -f -C <crash_pc>` → `addr2line_output.txt`;`objdump -d --disassemble=handle_request ./buggy_server | head -n 30` → `disasm_handle_request.txt`。
6. step 5:`gdbgui ./buggy_server --remap-sources -- core core.bin`,在浏览器界面按 view_01..view_06 顺序操作并截图。
7. step 6:综合三路证据写 `defect_analysis.json`(本案真因:`g_last_response` 全局指针在 `log_response()` 调用前已被 `free`,典型 use-after-free)。
8. step 7:编辑 `buggy_server.c` 修复(`free` 后置 `NULL` / 调整释放顺序 / `strdup` 拷贝 / 边界检查,由证据决定);`diff -u buggy_server.c.orig buggy_server.c > fix.patch`;`make` 重建 → `build_fixed.log`。
9. step 8:复跑 `loadgen.sh` 并继续 strace,`tail -n 300 /tmp/strace.raw > strace_post_tail.txt`(无 SIGSEGV);gdbgui 重新加载新二进制,原崩溃点设断点 → 截 `view_07` / `view_08`。
10. step 9:写 `diagnosis_report.md`,5 节齐全且 `Fix & Regression` 有可量化前后对比。

约束说明:
- `actions.log`(若 agent 框架产生)不得出现仅复制 prompt 文本来塞 `narrative` 字段的痕迹;`narrative` 必须由实际 strace 行 / addr2line 输出 / gdbgui 观察导出。
- 8 张截图 MD5 必须互不相同(防同图复用);单张 < 5 KB 视为占位空白,不计入。

评分要点(hard gates):
- CLI 证据(`strace_crash` + `addr2line`)与 GUI 证据(6 张 debug 截图)任一通道缺失,总分上限 0.35。
- 6 张 debug 截图缺一张上限 0.55,缺过半上限 0.40。
- `defect_analysis` 不到 0.5 上限 0.50,= 0 上限 0.40(`defect_class` 误判 / `suspect_function` 错 / `narrative` 不达标都会拉低)。
- `fix.patch` 未触及真 UAF 修复点上限 0.50,无 patch 上限 0.40。
- 修复后 `strace_post_tail.txt` 仍见 SIGSEGV 或行数不足上限 0.55。
- 截图 MD5 唯一性 < 0.75 上限 0.55(反 reuse 同图)。
- VLM rubric(gdbgui 真窗口 / Variables 面板 / Memory or Stack / fix verified)平均 < 0.6 上限 0.55,< 0.4 上限 0.30。

## Source

- gdbgui: https://github.com/cs01/gdbgui (GPL-3.0)
- strace(1): https://man7.org/linux/man-pages/man1/strace.1.html
- addr2line(1): https://man7.org/linux/man-pages/man1/addr2line.1.html
- CWE-416 Use After Free: https://cwe.mitre.org/data/definitions/416.html
- Linux core dump tutorial: https://man7.org/linux/man-pages/man5/core.5.html

## Grading Criteria

- [ ] 1. `build.log` / `server_pid.txt` 存在
- [ ] 2. `strace_crash_tail.txt` ≥ 100 行 + 含 mmap/munmap/write
- [ ] 3. `dmesg_segfault.txt` 含 segfault/SIGSEGV
- [ ] 4. `core.bin` 存在且非空
- [ ] 5. `view_01..view_06` 6 张 gdbgui 截图齐全 + OCR 命中 gdbgui / Variables / Call Stack / Memory 等关键词
- [ ] 6. `addr2line_output.txt` 含 `file.c:NN`
- [ ] 7. `disasm_handle_request.txt` 含汇编
- [ ] 8. `defect_analysis.json` schema 完整 + defect_class ∈ 5 类 + narrative ≥ 80 字
- [ ] 9. `fix.patch` 是合法 unified diff + 至少 3 行加号变更
- [ ] 10. `build_fixed.log` 存在 + `strace_post_tail.txt` 无 SIGSEGV
- [ ] 11. `view_07` / `view_08` 修复验证截图 + OCR 含 gdbgui
- [ ] 12. `diagnosis_report.md` ≥ 350 字 + 含 5 个标题节
- [ ] 13. VLM 验:gdbgui 真窗口 / Variables 面板 / Memory Viewer / fix verified
- [ ] 14. Cross-channel:strace/addr2line 文本产物 与 gdbgui 截图同时存在

## Automated Checks

```python
def grade(workspace_path=None, **kwargs) -> dict:
    """gdbgui + strace + addr2line use-after-free 诊断闭环 grader (v2 tightened)."""
    import json, re, hashlib
    from pathlib import Path
    try:
        from _judge_helper import vlm_score_rubric
    except Exception:
        vlm_score_rubric = None
    try:
        import pytesseract
        from PIL import Image
    except Exception:
        pytesseract = None
        Image = None

    workspace = Path(workspace_path) if workspace_path else Path("/tmp_workspace")
    rd = workspace / "results"
    s = {}

    def ocr_hits(path, kws):
        if not (pytesseract and Image and path.exists()):
            return False
        try:
            tx = pytesseract.image_to_string(Image.open(path)).lower()
        except Exception:
            return False
        return any(k.lower() in tx for k in kws)

    # 1. build.log + server_pid.txt
    bl = rd / "build.log"
    pid = rd / "server_pid.txt"
    s["build_artifacts"] = (int(bl.exists()) + int(pid.exists())) / 2.0

    # 2. strace_crash_tail.txt — require ≥100 lines AND ≥3 distinct syscalls from the set
    sc = rd / "strace_crash_tail.txt"
    if sc.exists():
        txt = sc.read_text(errors="ignore")
        lines = txt.strip().split("\n")
        sys_kws = ["mmap", "munmap", "write", "read", "brk", "close"]
        sys_hits = sum(1 for k in sys_kws if k in txt)
        if len(lines) >= 100 and sys_hits >= 3:
            s["strace_crash"] = 1.0
        elif len(lines) >= 50 and sys_hits >= 2:
            s["strace_crash"] = 0.5
        elif lines and sys_hits >= 1:
            s["strace_crash"] = 0.25
        else:
            s["strace_crash"] = 0.0
    else:
        s["strace_crash"] = 0.0

    # 3. dmesg_segfault.txt
    dm = rd / "dmesg_segfault.txt"
    if dm.exists():
        t = dm.read_text(errors="ignore").lower()
        s["dmesg_segfault"] = 1.0 if ("segfault" in t or "sigsegv" in t) else 0.3
    else:
        s["dmesg_segfault"] = 0.0

    # 4. core.bin
    cb = rd / "core.bin"
    s["core_dump"] = 1.0 if (cb.exists() and cb.stat().st_size > 100) else 0.0

    # 5. gdbgui screenshots phase 2 + 4 (6 of them)
    debug_shots = [
        "view_01_gdbgui_coredump_bt.png",
        "view_02_gdbgui_frame_jump.png",
        "view_03_gdbgui_breakpoint_hit.png",
        "view_04_gdbgui_step_to_release.png",
        "view_05_gdbgui_memory_viewer.png",
        "view_06_gdbgui_stack_regs.png",
    ]
    # require non-trivial size (>5KB) to count as present (anti-placeholder)
    def _valid_shot(p):
        return p.exists() and p.stat().st_size >= 5 * 1024
    present = sum(1 for n in debug_shots if _valid_shot(rd / n))
    s["debug_shots_present"] = present / len(debug_shots)
    kw = ["gdbgui", "breakpoint", "variables", "call stack", "registers",
          "source", "gdb", "console", "locals", "step", "continue", "memory"]
    if pytesseract and Image:
        hits = sum(1 for n in debug_shots if ocr_hits(rd / n, kw))
        s["debug_shots_ocr"] = hits / len(debug_shots)
    else:
        s["debug_shots_ocr"] = 0.5 if present else 0.0
    # md5 uniqueness across all 8 gdbgui screenshots (anti-cheat: same image reused)
    all_shots_for_md5 = debug_shots + [
        "view_07_gdbgui_fix_verified.png",
        "view_08_gdbgui_continue_no_crash.png",
    ]
    md5s = []
    for n in all_shots_for_md5:
        p = rd / n
        if _valid_shot(p):
            try:
                md5s.append(hashlib.md5(p.read_bytes()).hexdigest())
            except Exception:
                pass
    if md5s:
        s["shots_md5_uniqueness"] = len(set(md5s)) / len(md5s)
    else:
        s["shots_md5_uniqueness"] = 0.0

    # 6. addr2line + objdump
    al = rd / "addr2line_output.txt"
    if al.exists():
        s["addr2line"] = 1.0 if re.search(r"\w+\.c:\d+", al.read_text(errors="ignore")) else 0.3
    else:
        s["addr2line"] = 0.0
    da = rd / "disasm_handle_request.txt"
    if da.exists():
        t = da.read_text(errors="ignore")
        s["disasm"] = 1.0 if any(k in t for k in ["mov", "call", "lea", "ret", "push", "jmp"]) else 0.3
    else:
        s["disasm"] = 0.0

    # 7. defect_analysis.json — schema + correct defect_class (UAF) + narrative quality
    dj = rd / "defect_analysis.json"
    da_score = 0.0
    defect_class_correct = False
    if dj.exists():
        try:
            d = json.loads(dj.read_text())
            req = {"crash_addr","crash_file","crash_line","suspect_function","defect_class",
                   "evidence_strace_lines","evidence_addr2line","evidence_gdbgui_screenshot","narrative"}
            allowed = {"use_after_free","double_free","oob_write","uninit_read","null_deref"}
            if req <= set(d.keys()):
                da_score = 0.25
                if d.get("defect_class") in allowed:
                    da_score += 0.15
                # bonus: defect_class must actually be use_after_free (true root cause)
                if d.get("defect_class") == "use_after_free":
                    da_score += 0.20
                    defect_class_correct = True
                # narrative ≥80 chars AND must mention three evidence channels
                narr = d.get("narrative", "")
                if isinstance(narr, str) and len(narr) >= 80:
                    da_score += 0.15
                    nl = narr.lower()
                    chan_hits = sum(1 for k in ["strace", "addr2line", "gdbgui"] if k in nl)
                    if chan_hits >= 3:
                        da_score += 0.15
                # suspect_function must be handle_request (per Prompt + crash site)
                if d.get("suspect_function") == "handle_request":
                    da_score += 0.10
                da_score = min(da_score, 1.0)
        except Exception:
            pass
    s["defect_analysis"] = da_score
    s["defect_class_correct"] = 1.0 if defect_class_correct else 0.0

    # 8. fix.patch — must touch g_last_response or free/log_response area (true UAF fix)
    fp = rd / "fix.patch"
    if fp.exists():
        t = fp.read_text(errors="ignore")
        is_diff = ("---" in t and "+++" in t and "@@" in t)
        plus_lines = [l for l in t.splitlines() if l.startswith("+") and not l.startswith("+++")]
        plus = len(plus_lines)
        plus_blob = "\n".join(plus_lines).lower()
        # fix is meaningful if it touches g_last_response, free(response), or moves log_response
        meaningful = any(k in plus_blob for k in [
            "g_last_response", "log_response", "strdup", "memcpy", "= null"
        ])
        if is_diff and plus >= 3 and meaningful:
            s["fix_patch"] = 1.0
        elif is_diff and plus >= 3:
            s["fix_patch"] = 0.6
        elif is_diff:
            s["fix_patch"] = 0.3
        else:
            s["fix_patch"] = 0.0
    else:
        s["fix_patch"] = 0.0

    # 9. fixed build + post strace
    bf = rd / "build_fixed.log"
    s["build_fixed"] = 1.0 if bf.exists() else 0.0
    sp = rd / "strace_post_tail.txt"
    if sp.exists():
        t = sp.read_text(errors="ignore")
        tlow = t.lower()
        nlines = len(t.strip().split("\n"))
        no_crash = ("sigsegv" not in tlow) and ("segfault" not in tlow)
        # Prompt requires ≥200 lines for post-fix strace tail
        if no_crash and nlines >= 200:
            s["strace_post"] = 1.0
        elif no_crash and nlines >= 100:
            s["strace_post"] = 0.6
        elif no_crash:
            s["strace_post"] = 0.3
        else:
            s["strace_post"] = 0.0
    else:
        s["strace_post"] = 0.0

    # 10. fix verification screenshots (2) — same anti-placeholder size gate
    fv_shots = ["view_07_gdbgui_fix_verified.png", "view_08_gdbgui_continue_no_crash.png"]
    fv_present = sum(1 for n in fv_shots if _valid_shot(rd / n))
    s["fix_shots_present"] = fv_present / len(fv_shots)
    if pytesseract and Image:
        s["fix_shots_ocr"] = sum(1 for n in fv_shots if ocr_hits(rd / n, kw)) / len(fv_shots)
    else:
        s["fix_shots_ocr"] = 0.5 if fv_present else 0.0

    # 11. report
    rpt = rd / "diagnosis_report.md"
    if rpt.exists():
        t = rpt.read_text(errors="ignore")
        sections = ["## Root Cause","## strace Evidence","## addr2line Evidence",
                    "## gdbgui Evidence","## Fix & Regression"]
        sec_hits = sum(1 for sec in sections if sec.lower() in t.lower())
        s["report"] = 1.0 if (len(t) >= 350 and sec_hits >= 5) else (0.5 if sec_hits >= 3 else 0.2)
    else:
        s["report"] = 0.0

    # 12. cross-channel evidence (CLI + GUI co-present)
    has_cli_ev = (s["strace_crash"] > 0) and (s["addr2line"] > 0)
    has_gui_ev = (s["debug_shots_present"] >= 0.5)
    s["cross_channel_evidence"] = 1.0 if (has_cli_ev and has_gui_ev) else 0.0

    # VLM rubric (4 items)
    if vlm_score_rubric:
        all_shots = debug_shots + fv_shots
        sample = [str(rd / n) for n in all_shots if (rd / n).exists()][:4]
        if sample:
            rubric = {
                "vlm_gdbgui_real_window": "至少一张截图清晰显示 gdbgui 浏览器窗口(顶栏 gdbgui 字样 + 左侧源码面板带行号 + 底部 GDB Console)",
                "vlm_variables_panel": "至少一张截图能读到 Variables/Locals 面板列出变量名 + 当前值(非空)",
                "vlm_memory_or_stack": "至少一张截图能看到 Memory Viewer 的 hex 输出 或 Call Stack 面板的多帧列表",
                "vlm_fix_verified": "view_07/view_08 中能看出修复后断点能命中且程序未崩溃 Continue",
            }
            vlm = vlm_score_rubric(sample, rubric,
                instruction="评估 gdbgui 浏览器调试器在 use-after-free 诊断与修复验证中的截图真实性。")
            for k in rubric:
                s[k] = vlm.get(k, 0.0)
            s["judge_method"] = vlm.get("judge_method", "failed")

    # ---- Weighted aggregate: core 60% / gui 30% / aux 10% ----
    core_keys = ["defect_analysis", "defect_class_correct", "fix_patch",
                 "build_fixed", "strace_post", "report"]
    gui_keys = ["debug_shots_present", "debug_shots_ocr",
                "fix_shots_present", "fix_shots_ocr", "shots_md5_uniqueness"]
    vlm_keys = [k for k in s if k.startswith("vlm_")]
    gui_keys_full = gui_keys + vlm_keys
    aux_keys = ["build_artifacts", "strace_crash", "dmesg_segfault",
                "core_dump", "addr2line", "disasm", "cross_channel_evidence"]

    def _avg(keys):
        vals = [s[k] for k in keys if k in s and isinstance(s[k], (int, float))]
        return sum(vals) / len(vals) if vals else 0.0

    core = _avg(core_keys)
    gui = _avg(gui_keys_full)
    aux = _avg(aux_keys)
    base = 0.6 * core + 0.3 * gui + 0.1 * aux

    # ---- Hard gates (tightened for v2) ----
    # CLI/GUI evidence channels
    if not has_cli_ev:
        base = min(base, 0.35)
    if not has_gui_ev:
        base = min(base, 0.35)
    # Must have ALL 6 debug screenshots present (>=5KB) — partial cap
    if s.get("debug_shots_present", 0) < 1.0:
        base = min(base, 0.55)
    if s.get("debug_shots_present", 0) < 0.5:
        base = min(base, 0.40)
    # defect analysis correctness
    if s.get("defect_analysis", 0) < 0.5:
        base = min(base, 0.50)
    if s.get("defect_analysis", 0) == 0:
        base = min(base, 0.40)
    # fix patch must be meaningful
    if s.get("fix_patch", 0) < 0.6:
        base = min(base, 0.50)
    if s.get("fix_patch", 0) == 0:
        base = min(base, 0.40)
    # post-fix regression must show no crash
    if s.get("strace_post", 0) < 0.6:
        base = min(base, 0.55)
    # screenshot anti-cheat
    if s.get("shots_md5_uniqueness", 0) < 0.75:
        base = min(base, 0.55)
    # VLM thresholds — tighter, layered
    if vlm_keys:
        vlm_avg = sum(s[k] for k in vlm_keys) / len(vlm_keys)
        s["vlm_avg"] = vlm_avg
        if vlm_avg < 0.6:
            base = min(base, 0.55)
        if vlm_avg < 0.4:
            base = min(base, 0.30)
    else:
        # VLM unavailable → can't reach top tier
        base = min(base, 0.60)

    s["overall_score"] = float(max(0.0, min(1.0, base)))
    return s
```

## Workspace Path

```
workspace/OPS/task_1_strace_gdbgui_segfault
```

## Skills

```
```

## Env

```
```

## Warmup

```bash
echo d2hpY2ggZ2NjIHx8IChhcHQtZ2V0IHVwZGF0ZSAtcXEgJiYgREVCSUFOX0ZST05URU5EPW5vbmludGVyYWN0aXZlIGFwdC1nZXQgaW5zdGFsbCAteSAtcXEgZ2NjIGdkYiBzdHJhY2UgYmludXRpbHMgbGliYzYtZGV2KSA+L2Rldi9udWxsIDI+JjEgfHwgdHJ1ZQp3aGljaCB0ZXNzZXJhY3QgPi9kZXYvbnVsbCAyPiYxIHx8IGFwdC1nZXQgaW5zdGFsbCAteSAtcXEgdGVzc2VyYWN0LW9jciA+L2Rldi9udWxsIDI+JjEgfHwgdHJ1ZQp3aGljaCBjaHJvbWl1bSA+L2Rldi9udWxsIDI+JjEgfHwgd2hpY2ggY2hyb21p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