Skip to content
Agentmart
Submit a tool

tsan

Handle ThreadSanitizer output - redirect to files, summarize races, avoid context flooding

Skill by djmittens

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/djmittens-tsan

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Handle ThreadSanitizer output - redirect to files, summarize races, avoid context flooding

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/tsan

What's inside

Skill name
tsan
Description
Handle ThreadSanitizer output - redirect to files, summarize races, avoid context flooding
License
MIT
Compatibility
Requires bash and a C/C++ project with ThreadSanitizer-capable compiler
Metadata
category: testing · sanitizer: thread
Instructions
140 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# TSAN (ThreadSanitizer) Output Handling

Use this skill when running tests compiled with `-fsanitize=thread` or when encountering ThreadSanitizer output.

## Problem

TSAN produces verbose output (50-100+ lines per race) that can flood context. A test suite might report the same race hundreds of times.

## Quick Reference

### Recommended Test Invocation

```bash
# Always redirect TSAN output to file
TSAN_OPTIONS="log_path=build/tsan.log:halt_on_error=0:history_size=2" ./test_binary

# Then summarize (don't cat the whole file!)
echo "=== TSAN Summary ==="
grep -c "WARNING: ThreadSanitizer" build/tsan.log 2>/dev/null || echo "0 races"
grep -A2 "WARNING: ThreadSanitizer" build/tsan.log | grep "#0" | sort -u | head -10
```

### Stop After First Race (For Debugging)

```bash
TSAN_OPTIONS="halt_on_error=1" ./test_binary
```

### Use Suppressions (For Known Issues)

Create `tsan_suppressions.txt`:
```
# Suppress by function name
race:KnownRacyFunction

# Suppress by file
race:src/legacy/old_code.cc

# Suppress entire library  
called_from_lib:libthirdparty.so

# Suppress by global variable
race:global_counter
```

Run with:
```bash
TSAN_OPTIONS="suppressions=tsan_suppressions.txt" ./test_binary
```

## NEVER Do This

```bash
# WRONG - floods context with potentially thousands of lines
./test_binary 2>&1

# WRONG - still floods context  
./test_binary 2>&1 | head -500  # 500 lines is still too much
```

## Summarizing TSAN Output

After running tests, summarize the log file:

```bash
# Count total races
RACE_COUNT=$(grep -c "WARNING: ThreadSanitizer" build/tsan.log 2>/dev/null || echo "0")
echo "Total TSAN reports: $RACE_COUNT"

# Get unique race locations (first stack frame only)
echo "Unique race locations:"
grep -A3 "WARNING: ThreadSanitizer" build/tsan.log | \
  grep "#0" | \
  sed 's/.*#0 //' | \
  sort | uniq -c | sort -rn | head -10
```

## Creating Issues from TSAN Output

When TSAN reports races, create concise issues:

```bash
tix issue add '{"desc":"TSAN: data race in Worker::process (src/worker.cc:123)"}'
```

NOT verbose multi-line descriptions with full stack traces.

## TSAN_OPTIONS Reference

| Option | Value | Effect |
|--------|-------|--------|
| `log_path` | `path/to/file` | Redirect output to file |
| `halt_on_error` | `0` or `1` | Stop after first race |
| `history_size` | `0-7` | Stack trace memory (0=smallest) |
| `suppressions` | `path/to/file` | Suppression rules file |
| `verbosity` | `0-2` | Output verbosity |

Combine with colons:
```bash
TSAN_OPTIONS="log_path=out.log:halt_on_error=1:history_size=2"
```

## Suppression Types

| Type | Matches Against |
|------|-----------------|
| `race` | Function/file in either stack |
| `race_top` | Only top stack frame |
| `thread` | Thread leak reports |
| `mutex` | Locked mutex destruction |
| `signal` | Signal handler issues |
| `deadlock` | Lock inversion reports |
| `called_from_lib` | Calls from specific library |

## Example Workflow

1. **Run tests with output redirected:**
   ```bash
   TSAN_OPTIONS="log_path=build/tsan.log" make test-tsan

From djmittens/neo-mittens, MIT.

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
May 19, 2026 (5 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from djmittens

Cite this page

tsan skill. Agent Mart. https://agentmart.dev/skills/djmittens-tsan (last updated 2026-10-24)