File contents nginx.org C Module Debugging Best Practices
Comprehensive debugging guide for nginx C modules, derived from the official nginx development documentation and production debugging experience. Contains 45 rules across 8 categories, prioritized by impact to guide systematic diagnosis of crashes, memory bugs, and behavioral issues in nginx modules.
Companion skills : This skill complements nginx-c-modules (correctness) and nginx-c-module-perf-reliability (performance). This skill covers debugging and diagnosis .
When to Apply
Reference these guidelines when:
Diagnosing nginx worker crashes (segfaults, SIGABRT, SIGSEGV)
Finding memory bugs (use-after-free, leaks, pool corruption, buffer overruns)
Setting up GDB and core dump analysis for nginx
Tracing request flow through phases, subrequests, and filter chains
Instrumenting nginx modules with debug logging and dynamic tracing tools
Rule Categories by Priority
Priority
Category
Impact
Prefix
1
Crash Diagnosis & Signals
CRITICAL
crash-
2
Memory Bug Detection
CRITICAL
memdbg-
3
GDB & Core Dump Analysis
HIGH
gdb-
4
Request Flow Tracing
HIGH
trace-
5
Debug Logging Patterns
MEDIUM-HIGH
dbglog-
6
State & Lifecycle Debugging
MEDIUM
state-
7
Dynamic Tracing Tools
MEDIUM
probe-
8
Build & Sanitizer Configuration
LOW-MEDIUM
build-
Quick Reference
1. Crash Diagnosis & Signals (CRITICAL)
crash-segfault-signature - Identify Segfault Crash Signature from Signal and Address
crash-null-deref-pattern - Recognize NULL Pointer Dereference Patterns in nginx Modules
crash-double-free-finalize - Diagnose Double Finalize Crashes from Request Reference Count
crash-stack-overflow - Detect Stack Overflow from Recursive Subrequest or Filter Chains
crash-worker-exit-log - Extract Crash Context from Worker Exit Log Messages
crash-error-page-redirect - Avoid Crashes from error_page Internal Redirect Context Invalidation
2. Memory Bug Detection (CRITICAL)
memdbg-use-after-free - Detect Use-After-Free from Pool Destruction Timing
memdbg-pool-leak-pattern - Identify Pool Memory Leak Patterns from Growing Worker RSS
memdbg-slab-corruption - Diagnose Shared Memory Slab Corruption from Multi-Worker Crashes
memdbg-cleanup-handler-leak - Detect Resource Leaks from Missing Pool Cleanup Handlers
memdbg-buffer-overrun - Find Buffer Overrun from ngx_pnalloc Size Miscalculation
memdbg-temp-pool-misuse - Avoid Storing Long-Lived Pointers in Temporary Pools
memdbg-valgrind-pool-trace - Use Valgrind Pool-Level Tracing to Find Leaked Allocations
3. GDB & Core Dump Analysis (HIGH)
gdb-coredump-setup - Configure Core Dump Generation for nginx Worker Crashes
gdb-attach-worker - Attach GDB to a Running nginx Worker Process
gdb-backtrace-read - Read nginx Backtrace to Identify Crash Module and Phase
gdb-inspect-request - Inspect ngx_http_request_t Fields in GDB for Request State
gdb-memory-buffer-extract - Extract Debug Log from Memory Buffer Using GDB Script
gdb-watchpoint-corruption - Use GDB Watchpoints to Catch Memory Corruption at Write Time
4. Request Flow Tracing (HIGH)
trace-phase-handler-flow - Trace Request Through HTTP Phase Handlers
trace-subrequest-tree - Map Subrequest Parent-Child Relationships for Debugging
trace-filter-chain-order - Trace Filter Chain Execution Order and Data Flow
trace-upstream-callback-seq - Trace Upstream Callback Sequence for Proxy Debugging
trace-event-handler-chain - Trace Event Handler Execution for Connection Debugging
trace-config-inheritance - Trace Configuration Inheritance Through Server and Location Blocks
5. Debug Logging Patterns (MEDIUM-HIGH)
dbglog-debug-mask - Use Correct Debug Mask for Targeted Log Filtering
dbglog-debug-connection - Use debug_connection to Isolate Single-Client Debug Output
dbglog-memory-buffer - Use Memory Buffer Logging to Capture Debug Output Without Disk I/O
dbglog-log-action-string - Set Log Action String for Context in Error Messages
dbglog-format-ngx-str - Format ngx_str_t Correctly in Debug Log Messages
6. State & Lifecycle Debugging (MEDIUM)
state-connection-lifecycle - Track Connection State Transitions for Lifecycle Debugging
state-upstream-state-machine - Debug Upstream Module State by Logging Transition Points
state-timer-leak - Detect Timer Leaks from Events Not Removed Before Pool Destruction
state-event-flag-debug - Inspect Event Flags to Debug Unexpected Handler Invocation
state-request-count-track - Track Request Reference Count to Debug Premature Destruction
7. Dynamic Tracing Tools (MEDIUM)
probe-strace-syscall - Use strace to Trace System Call Patterns in nginx Workers
probe-dtrace-request - Trace Request Processing with DTrace pid Provider
probe-systemtap-pool - Trace Memory Pool Allocations with SystemTap
probe-ebpf-latency - Measure Per-Function Latency with eBPF Probes
probe-strace-fd-leak - Detect File Descriptor Leaks with strace and /proc
8. Build & Sanitizer Configuration (LOW-MEDIUM)
build-debug-flags - Compile nginx with Full Debug Symbols and No Optimization
build-asan-configure - Build nginx with AddressSanitizer for Memory Error Detection
build-single-process - Use Single-Process Mode for Simplified Debugging
build-valgrind-suppressions - Use nginx Valgrind Suppressions to Reduce False Positives
build-debug-palloc - Enable NGX_DEBUG_PALLOC for Fine-Grained Pool Allocation Tracking
How to Use
Read individual reference files for detailed explanations and code examples:
Section definitions - Category structure and impact levels
Rule template - Template for adding new rules
Reference Files
File
Description
references/_sections.md
Category definitions and ordering
assets/templates/_template.md
Template for new rules
metadata.json
Version and reference information
1 --- 2 name: nginx-c-module-debug 3 description: nginx.org C Module Debugging Best Practices 4 --- 5 # nginx.org C Module Debugging Best Practices 6 7 Comprehensive debugging guide for nginx C modules, derived from the official nginx development documentation and production debugging experience. Contains 45 rules across 8 categories, prioritized by impact to guide systematic diagnosis of crashes, memory bugs, and behavioral issues in nginx modules. 8 9 **Companion skills**: This skill complements [nginx-c-modules](../nginx-c-modules/SKILL.md) (correctness) and [nginx-c-module-perf-reliability](../nginx-c-module-perf/SKILL.md) (performance). This skill covers **debugging and diagnosis**. 10 11 ## When to Apply 12 13 Reference these guidelines when: 14 - Diagnosing nginx worker crashes (segfaults, SIGABRT, SIGSEGV) 15 - Finding memory bugs (use-after-free, leaks, pool corruption, buffer overruns) 16 - Setting up GDB and core dump analysis for nginx 17 - Tracing request flow through phases, subrequests, and filter chains 18 - Instrumenting nginx modules with debug logging and dynamic tracing tools 19 20 ## Rule Categories by Priority 21 22 | Priority | Category | Impact | Prefix | 23 |----------|----------|--------|--------| 24 | 1 | Crash Diagnosis & Signals | CRITICAL | `crash-` | 25 | 2 | Memory Bug Detection | CRITICAL | `memdbg-` | 26 | 3 | GDB & Core Dump Analysis | HIGH | `gdb-` | 27 | 4 | Request Flow Tracing | HIGH | `trace-` | 28 | 5 | Debug Logging Patterns | MEDIUM-HIGH | `dbglog-` | 29 | 6 | State & Lifecycle Debugging | MEDIUM | `state-` | 30 | 7 | Dynamic Tracing Tools | MEDIUM | `probe-` | 31 | 8 | Build & Sanitizer Configuration | LOW-MEDIUM | `build-` | 32 33 ## Quick Reference 34 35 ### 1. Crash Diagnosis & Signals (CRITICAL) 36 37 - [`crash-segfault-signature`](references/crash-segfault-signature.md) - Identify Segfault Crash Signature from Signal and Address 38 - [`crash-null-deref-pattern`](references/crash-null-deref-pattern.md) - Recognize NULL Pointer Dereference Patterns in nginx Modules 39 - [`crash-double-free-finalize`](references/crash-double-free-finalize.md) - Diagnose Double Finalize Crashes from Request Reference Count 40 - [`crash-stack-overflow`](references/crash-stack-overflow.md) - Detect Stack Overflow from Recursive Subrequest or Filter Chains 41 - [`crash-worker-exit-log`](references/crash-worker-exit-log.md) - Extract Crash Context from Worker Exit Log Messages 42 - [`crash-error-page-redirect`](references/crash-error-page-redirect.md) - Avoid Crashes from error_page Internal Redirect Context Invalidation 43 44 ### 2. Memory Bug Detection (CRITICAL) 45 46 - [`memdbg-use-after-free`](references/memdbg-use-after-free.md) - Detect Use-After-Free from Pool Destruction Timing 47 - [`memdbg-pool-leak-pattern`](references/memdbg-pool-leak-pattern.md) - Identify Pool Memory Leak Patterns from Growing Worker RSS 48 - [`memdbg-slab-corruption`](references/memdbg-slab-corruption.md) - Diagnose Shared Memory Slab Corruption from Multi-Worker Crashes 49 - [`memdbg-cleanup-handler-leak`](references/memdbg-cleanup-handler-leak.md) - Detect Resource Leaks from Missing Pool Cleanup Handlers 50 - [`memdbg-buffer-overrun`](references/memdbg-buffer-overrun.md) - Find Buffer Overrun from ngx_pnalloc Size Miscalculation 51 - [`memdbg-temp-pool-misuse`](references/memdbg-temp-pool-misuse.md) - Avoid Storing Long-Lived Pointers in Temporary Pools 52 - [`memdbg-valgrind-pool-trace`](references/memdbg-valgrind-pool-trace.md) - Use Valgrind Pool-Level Tracing to Find Leaked Allocations 53 54 ### 3. GDB & Core Dump Analysis (HIGH) 55 56 - [`gdb-coredump-setup`](references/gdb-coredump-setup.md) - Configure Core Dump Generation for nginx Worker Crashes 57 - [`gdb-attach-worker`](references/gdb-attach-worker.md) - Attach GDB to a Running nginx Worker Process 58 - [`gdb-backtrace-read`](references/gdb-backtrace-read.md) - Read nginx Backtrace to Identify Crash Module and Phase 59 - [`gdb-inspect-request`](references/gdb-inspect-request.md) - Inspect ngx_http_request_t Fields in GDB for Request State 60 - [`gdb-memory-buffer-extract`](references/gdb-memory-buffer-extract.md) - Extract Debug Log from Memory Buffer Using GDB Script 61 - [`gdb-watchpoint-corruption`](references/gdb-watchpoint-corruption.md) - Use GDB Watchpoints to Catch Memory Corruption at Write Time 62 63 ### 4. Request Flow Tracing (HIGH) 64 65 - [`trace-phase-handler-flow`](references/trace-phase-handler-flow.md) - Trace Request Through HTTP Phase Handlers 66 - [`trace-subrequest-tree`](references/trace-subrequest-tree.md) - Map Subrequest Parent-Child Relationships for Debugging 67 - [`trace-filter-chain-order`](references/trace-filter-chain-order.md) - Trace Filter Chain Execution Order and Data Flow 68 - [`trace-upstream-callback-seq`](references/trace-upstream-callback-seq.md) - Trace Upstream Callback Sequence for Proxy Debugging 69 - [`trace-event-handler-chain`](references/trace-event-handler-chain.md) - Trace Event Handler Execution for Connection Debugging 70 - [`trace-config-inheritance`](references/trace-config-inheritance.md) - Trace Configuration Inheritance Through Server and Location Blocks 71 72 ### 5. Debug Logging Patterns (MEDIUM-HIGH) 73 74 - [`dbglog-debug-mask`](references/dbglog-debug-mask.md) - Use Correct Debug Mask for Targeted Log Filtering 75 - [`dbglog-debug-connection`](references/dbglog-debug-connection.md) - Use debug_connection to Isolate Single-Client Debug Output 76 - [`dbglog-memory-buffer`](references/dbglog-memory-buffer.md) - Use Memory Buffer Logging to Capture Debug Output Without Disk I/O 77 - [`dbglog-log-action-string`](references/dbglog-log-action-string.md) - Set Log Action String for Context in Error Messages 78 - [`dbglog-format-ngx-str`](references/dbglog-format-ngx-str.md) - Format ngx_str_t Correctly in Debug Log Messages 79 80 ### 6. State & Lifecycle Debugging (MEDIUM) 81 82 - [`state-connection-lifecycle`](references/state-connection-lifecycle.md) - Track Connection State Transitions for Lifecycle Debugging 83 - [`state-upstream-state-machine`](references/state-upstream-state-machine.md) - Debug Upstream Module State by Logging Transition Points 84 - [`state-timer-leak`](references/state-timer-leak.md) - Detect Timer Leaks from Events Not Removed Before Pool Destruction 85 - [`state-event-flag-debug`](references/state-event-flag-debug.md) - Inspect Event Flags to Debug Unexpected Handler Invocation 86 - [`state-request-count-track`](references/state-request-count-track.md) - Track Request Reference Count to Debug Premature Destruction 87 88 ### 7. Dynamic Tracing Tools (MEDIUM) 89 90 - [`probe-strace-syscall`](references/probe-strace-syscall.md) - Use strace to Trace System Call Patterns in nginx Workers 91 - [`probe-dtrace-request`](references/probe-dtrace-request.md) - Trace Request Processing with DTrace pid Provider 92 - [`probe-systemtap-pool`](references/probe-systemtap-pool.md) - Trace Memory Pool Allocations with SystemTap 93 - [`probe-ebpf-latency`](references/probe-ebpf-latency.md) - Measure Per-Function Latency with eBPF Probes 94 - [`probe-strace-fd-leak`](references/probe-strace-fd-leak.md) - Detect File Descriptor Leaks with strace and /proc 95 96 ### 8. Build & Sanitizer Configuration (LOW-MEDIUM) 97 98 - [`build-debug-flags`](references/build-debug-flags.md) - Compile nginx with Full Debug Symbols and No Optimization 99 - [`build-asan-configure`](references/build-asan-configure.md) - Build nginx with AddressSanitizer for Memory Error Detection 100 - [`build-single-process`](references/build-single-process.md) - Use Single-Process Mode for Simplified Debugging 101 - [`build-valgrind-suppressions`](references/build-valgrind-suppressions.md) - Use nginx Valgrind Suppressions to Reduce False Positives 102 - [`build-debug-palloc`](references/build-debug-palloc.md) - Enable NGX_DEBUG_PALLOC for Fine-Grained Pool Allocation Tracking 103 104 ## How to Use 105 106 Read individual reference files for detailed explanations and code examples: 107 108 - [Section definitions](references/_sections.md) - Category structure and impact levels 109 - [Rule template](assets/templates/_template.md) - Template for adding new rules 110 111 ## Reference Files 112 113 | File | Description | 114 |------|-------------| 115 | [references/_sections.md](references/_sections.md) | Category definitions and ordering | 116 | [assets/templates/_template.md](assets/templates/_template.md) | Template for new rules | 117 | [metadata.json](metadata.json) | Version and reference information |
ComeOnOliver/skillshub/tree/main/skills/pproenca/dot-skills/nginx-c-module-debug commit ec8b0b6078
Frequently asked questions How do I install the Nginx C Module Debug skill? Run npx skillmds@latest add comeonoliver/nginx-c-module-debug in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Nginx C Module Debug skill do? nginx.org C Module Debugging Best Practices It is listed under Coding & Dev Tools on SkillMD.
Is Nginx C Module Debug safe to use? This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Nginx C Module Debug? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Nginx C Module Debug free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Nginx C Module Debug? ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.