find-postgres-bug
यह क्या करती है
यह स्किल PostgreSQL सोर्स चेकआउट में debug build और स्वचालित fuzzing से crash बग खोजती है। यह उन PostgreSQL डेवलपर्स और योगदानकर्ताओं के लिए है जो असली खामियां ढूंढकर रिपोर्ट करना चाहते हैं।
कब इस्तेमाल करें
- ✓जब आप स्थानीय PostgreSQL सोर्स ट्री में crash बग खोजना चाहते हैं।
- ✓जब आपको fuzzing के साथ जांच के लिए PostgreSQL का debug build चाहिए।
- ✓जब आपको समुदाय के लिए न्यूनतम reproducer और बग रिपोर्ट चाहिए।
Skill का लिंक
https://github.com/digoal/blog/blob/master/skills/find-postgres-bug/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे PostgreSQL चेकआउट का debug संस्करण बनाइए, उसे crash के लिए fuzz कीजिए, और जो मिले उसका न्यूनतम test case बनाइए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
यह सख़्त debug इंस्टेंस बनाती है, सर्वर crash होने तक fuzzer चलाती है, crash core पढ़ती है, इनपुट छोटा करती है, और जांचती है कि कौन सा commit समस्या लाया।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Find Postgres Bug
Overview
Crash-first bug-hunting pipeline for a local PostgreSQL source tree. The order matters and is the whole point:
poison the build → fuzz it → triage the core → minimise to an MRE
→ bisect the commit → report (do NOT self-patch)
The leverage is front-loaded. A poisoned build does ~90% of the work by turning latent bugs into immediate crashes; the fuzzer then finds inputs no human would hand-write. Reading commits by eye is a secondary, targeted probe — used to aim the fuzzer, not as the primary search.
Source layout assumed: the standard PG tree (src/backend/,
src/include/, contrib/, src/test/, …) at $PG_SRC_DIR.
Three hard rules:
- The skill never auto-stops the instance. Run
scripts/stop_pg.shexplicitly when done. - Never write a patch. The deliverable is an MRE + backtrace + bisect result, posted upstream. A drive-by fix from someone who just met the code is worth less than a clean reproducer.
- A finding only counts if it crashes at HEAD, with the tree exactly as committed. Never revert a fix (or commit a staged revert) to make something crash and call it a bug — that just re-creates an already-fixed bug and is worthless. Before investing in any candidate, run the pre-flight in Step 0. See references/already_fixed.md.
Quick start
export PG_SRC_DIR=/path/to/postgres
# 1. POISON: configure+build+initdb+start with cassert, cache-discard,
# -O0 -ggdb3, core dumps enabled. The 90% lever.
./scripts/build_and_start_pg.sh
# 2. SEED + FUZZ: load some tables, then let sqlsmith run (overnight is best)
psql -h /tmp -p 55432 -d postgres -f your_schema.sql # populate the catalog
./scripts/fuzz_sqlsmith.sh 3600 postgres # 1h; use 28800 overnight
# 3. TRIAGE: a crash leaves a core under $PGDATA
./scripts/triage_core.sh /path/to/$PGDATA/core.NNNN
# 4. MINIMISE: cut the failing query down, confirm it crashes on demand
$EDITOR repro/mybug.sql
./scripts/run_repro.sh repro/mybug.sql mybug # "SERVER IS DOWN" = good
# 5. BISECT: find the commit that introduced it
./scripts/bisect_run.sh repro/mybug.sql REL_17_STABLE HEAD
# 6. REPORT: render markdown for pgsql-bugs (no patch)
$EDITOR /tmp/bug.yaml
./scripts/gen_bug_report.sh /tmp/bug.yaml
# when finished:
./scripts/stop_pg.sh
If a real crash surfaces, the markdown is ready for [pgsql-bugs]. If the fuzzer runs clean, broaden the seed schema / run longer / switch branch.
Workflow
Each step has a success criterion to verify before moving on.
Step 0 — Pre-flight: clean tree & live-at-HEAD gate (do this first)
Before building or investing in any candidate, rule out the two biggest time-wasters: a dirty working tree, and a "bug" that HEAD already fixed.
cd "$PG_SRC_DIR"
git status --short # any M/MM/A? the tree is NOT as-committed
git stash list # stashed reverts hide here too
- Dirty tree → stop and ask. Uncommitted edits (especially a staged
revert of a fix) mean you are no longer testing HEAD. A
git commitcould re-introduce a fixed bug. Surface this to the user and do not build on top of it. Nevergit commit,git checkout,git restore, orgit stashaway the user's changes without explicit permission. - Always build and test the tree exactly as committed. Do not revert a fix to "reproduce" a bug. If you ever need to confirm a fix works, that is a fix-verification task, not a bug find — label it as such and do not report it as a new bug.
When the target is a specific commit (the user said "test this commit" or you picked one in Step 6), check it is not already superseded:
./scripts/check_already_fixed.sh <hash> # is it in HEAD? any later "Fix"/revert touching the same files?
Success: git status is clean (or the user has explicitly accepted a
dirty tree), and the candidate commit is confirmed not already fixed or
reverted upstream. Only then proceed to Step 1. Details and edge cases:
references/already_fixed.md.
Step 1 — Poison the build & start (the 90% lever)
export PG_SRC_DIR=/path/to/postgres
./scripts/build_and_start_pg.sh
Runs ./configure --enable-debug --enable-cassert --enable-debug-symbols --enable-tap-tests with CFLAGS="-O0 -ggdb3",
auto-detects the cache-poison mechanism by **grepping the tree
अक्सर पूछे जाने वाले सवाल
क्या यह मेरे लिए बग ठीक करेगी?
नहीं, स्किल patch लिखने से मना करती है, और उसका आउटपुट reproducer और रिपोर्ट होता है।
असली खोज किसे माना जाता है?
खोज तभी गिनी जाती है जब वह मौजूदा ट्री पर ठीक उसी तरह crash करे जैसे वह commit हुआ है।
क्या टेस्ट सर्वर अपने-आप बंद होता है?
नहीं, काम खत्म होने पर आपको stop script खुद चलानी होगी।
जानकारी
लेखक का मूल विवरण
Find latent bugs in a local PostgreSQL source tree (REL_xx_STABLE branch or HEAD) the way a core hacker does: build a heavily-poisoned debug instance (cassert + cache-discard + -O0/-ggdb3 + core dumps), fuzz it (sqlsmith) until the backend crashes, triage the core into a minimal reproducer (MRE), git-bisect the introducing commit, and render a community-style pgsql-bugs markdown report. The instance never auto-shuts-down. Use when the user says "find a bug in postgres", "fuzz postgres", "hunt for a crash", "test a recent commit", "write a repro", "bisect this crash", "把 PG 跑起来找 bug", "fuzz 一下
repo: digoal/blog
लोकप्रियता
- GitHub स्टार
- 8.6k
- रैंकिंग में स्थान
- #12363
- लाइसेंस
- GPL-2.0
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
article-to-podcast-script
8.6kयह आपके एजेंट को Markdown लेख से एक से चार वक्ताओं वाली पॉडकास्ट स्क्रिप्ट बनाने में मदद करती है, जो टेक्स्ट फ़ाइल में सहेजी जाती है।
axiom-explainer
8.6kयह आपके एजेंट को किसी एक दृष्टिकोण, नियम या सिद्धांत को उदाहरणों, सीमाओं और सरल चित्रों के साथ समझाने वाला स्पष्ट चीनी लेख लिखने में मदद करती है।
blog-cover-poster
8.6kयह आपके एजेंट को लेख या नोट्स से वर्टिकल पोस्टर इमेज का सेट बनाने में मदद करती है, जिसमें एक कवर और मुख्य बिंदु समझाने वाली कई स्लाइड हों।
buffett
8.6kयह आपके एजेंट को Warren Buffett की सोच से कंपनी और शेयर पर विचार करने में मदद करती है, moat, प्रबंधन और margin of safety के आधार पर।
मिलती-जुलती skills
test-driven-development
311kयह आपके एजेंट को किसी भी फ़ीचर या सुधार से पहले पहले असफल होने वाला टेस्ट लिखना, उसे असफल होते देखना, फिर पास करने वाला सबसे छोटा कोड लिखना सिखाती है।
verification-before-completion
311kयह आपके एजेंट को किसी काम, सुधार या build के पूरा या पास होने का दावा करने से पहले असली जांच चलाकर उसका आउटपुट पढ़ना सिखाती है।
migrate-to-shoehorn
310kआपकी टेस्ट फ़ाइलों में जोखिम भरे type casts की जगह shoehorn लाइब्रेरी लगाती है, ताकि टेस्ट अधूरे डेटा से भी type checks पास कर सकें।