Token导航 LogoToken导航TokenDH.com
运维和基础设施需要联网github未标认证来源可访问clear审计通过

custom-memory-heap-crash自定义内存堆崩溃

Agent Skill

custom-memory-heap-crash 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

808

周安装

33

GitHub Stars

93

下载量

259
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:custom-memory-heap-crash(自定义内存堆崩溃)
来源仓库:https://github.com/letta-ai/skills
仓库路径:skills/custom-memory-heap-crash
安装命令:
npx skills add https://github.com/letta-ai/skills --skill custom-memory-heap-crash
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/letta-ai/skills --skill custom-memory-heap-crash

简介

custom-memory-heap-crash 调试自定义内存堆导致的崩溃问题,特别是静态析构顺序异常。

  • 重点排查 DEBUG 与 RELEASE 构建间的行为差异。
  • 适用于标准库组件(如 locale、iostream)中的内存生命周期问题。
  • 建议结合日志与内存快照分析定位具体失效点。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Custom Memory Heap Crash Debugging

This skill provides systematic approaches for debugging crashes related to custom memory heaps, with emphasis on static destruction ordering issues, DEBUG vs RELEASE discrepancies, and memory lifecycle problems.

Problem Recognition

Apply this skill when encountering:

  • Crashes that occur only in RELEASE builds but not DEBUG builds
  • Segmentation faults or access violations during program shutdown
  • Use-after-free errors involving custom allocators
  • Crashes in standard library code (locale, iostream, etc.) when custom heaps are involved
  • Memory lifecycle issues during static destruction phase

Investigation Approach

Phase 1: Reproduce and Characterize

  1. Build both configurations: Compile the application in both DEBUG and RELEASE modes to confirm the discrepancy
  2. Identify crash timing: Determine if the crash occurs during:

- Normal execution - Program shutdown (static destruction phase) - Library initialization

  1. Collect crash information: Use GDB or equivalent debugger to obtain:

- Full backtrace at crash point - Register values and memory state - The specific instruction causing the crash

Phase 2: Understand Memory Lifecycle

  1. Map allocator lifecycle: Document when custom heaps are:

- Created (constructor timing) - Active (during main execution) - Destroyed (destructor timing)

  1. Identify static objects: List all static/global objects that may allocate memory
  2. Trace allocation sources: Determine which allocator (custom vs system) handles each allocation

Phase 3: Analyze Static Destruction Order

  1. Review destruction sequence: Static objects are destroyed in reverse order of construction
  2. Check cross-dependencies: Identify objects that depend on the custom heap but may be destroyed after it
  3. Examine library internals: Standard library components (locales, facets, streams) may register objects that outlive custom heaps

Common Root Causes

Use-After-Free During Static Destruction

Pattern: Objects allocated from a custom heap are accessed after the heap is destroyed.

Symptoms:

  • Crash in destructor or cleanup code
  • Backtrace shows standard library cleanup (e.g., locale facet destruction)
  • Crash accesses memory that was valid earlier

Investigation:

  • Check if standard library objects (locale facets, stream buffers) are allocated from the custom heap
  • Verify the custom heap outlives all its allocations

DEBUG vs RELEASE Allocation Differences

Pattern: Different allocation patterns between build configurations cause memory to come from different sources.

Symptoms:

  • Works in DEBUG, crashes in RELEASE
  • Memory addresses differ between configurations
  • Conditional compilation affects allocator selection

Investigation:

  • Examine preprocessor conditionals affecting memory allocation
  • Check if DEBUG mode uses system allocator while RELEASE uses custom heap
  • Look for #ifdef DEBUG or #ifndef NDEBUG blocks around allocation code

Library-Internal Allocations

Pattern: Standard library internally allocates memory that gets routed through custom allocators.

Symptoms:

  • Crash during library cleanup code
  • Backtrace shows internal library functions
  • No obvious user code involvement

Investigation:

  • Trace which library operations trigger allocations
  • Check if locale, iostream, or other library initializations use the custom heap
  • Examine library source code if available

Solution Strategies

Strategy 1: Force Early Initialization

Trigger library initialization before the custom heap is created, ensuring library-internal allocations use the system allocator.

Implementation approach:

  • Call library functions in user_init() or before heap creation
  • For locale issues: instantiate std::locale() early
  • For iostream issues: perform I/O operations early

Strategy 2: Extend Heap Lifetime

Ensure the custom heap outlives all objects allocated from it.

Implementation approach:

  • Use static local variables with guaranteed destruction order
  • Implement explicit cleanup before heap destruction
  • Consider lazy destruction or leaking the heap intentionally

Strategy 3: Exclude Library Allocations

Prevent library-internal allocations from using the custom heap.

Implementation approach:

  • Modify allocator selection logic to exclude certain allocation types
  • Use thread-local flags during library initialization
  • Implement allocation source tracking

Verification Checklist

After implementing a fix:

  1. Build verification: Confirm both DEBUG and RELEASE builds compile without errors
  2. Runtime verification: Run both configurations without crashes
  3. Memory leak check: Use Valgrind or equivalent to verify no memory leaks introduced
  4. Stress testing: Run multiple iterations to catch intermittent issues
  5. Destruction order verification: Confirm proper cleanup sequence with logging if needed

Debugging Tools and Techniques

GDB Commands for Memory Issues

# Get backtrace at crash
bt full

# Examine memory at address
x/16xg <address>

# Check if address is valid
info proc mappings

# Set breakpoint on destructor
break ClassName::~ClassName

# Watch memory location
watch *<address>

Valgrind Usage

# Basic memory check
valgrind --leak-check=full ./program

# Track origins of uninitialized values
valgrind --track-origins=yes ./program

# Detect invalid reads/writes
valgrind --read-var-info=yes ./program

Common Pitfalls

  1. Incomplete initialization: Triggering partial library initialization may not allocate all necessary objects. Verify the specific code path that causes problematic allocations.
  2. Multiple initialization points: Library components may be initialized from multiple code paths. Ensure all paths are covered.
  3. Thread safety assumptions: Static initialization may involve thread-safety mechanisms that interact with custom allocators.
  4. Optimization effects: Compiler optimizations may reorder or eliminate code that affects allocation timing.
  5. GDB command syntax: When debugging, use proper quoting and escaping. Test commands interactively before scripting.
  6. Assuming single root cause: Multiple allocation sources may contribute to the problem. Verify each fix addresses all crash scenarios.

Decision Framework

When investigating, follow this systematic approach:

  1. Can the crash be reproduced reliably? If not, add logging to capture crash state.
  2. Is this a DEBUG vs RELEASE discrepancy? Check preprocessor conditionals.
  3. Does the crash occur during shutdown? Focus on static destruction order.
  4. Is library code involved? Investigate library initialization and cleanup.
  5. Is memory being accessed after free? Trace the allocation source and lifetime.

Apply fixes incrementally and verify each change before proceeding.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

28.76%
按下载量换算74

Gemini CLI

22.8%
按下载量换算59

Antigravity

14.96%
按下载量换算39

windsurf

13.21%
按下载量换算34

Codex

8.17%
按下载量换算21

OpenCode

3.41%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills