infer-pulse-eval / README.md
shubhamugare's picture
Upload README.md with huggingface_hub
c475ce4 verified
metadata
license: mit
task_categories:
  - text-classification
  - text-generation
language:
  - en
tags:
  - code
  - static-analysis
  - bug-detection
  - c
  - memory-safety
size_categories:
  - n<1K

Infer Pulse Static Analysis Evaluation Dataset

Dataset Description

This dataset contains 523 C functions extracted from Meta's Infer static analyzer test suite, specifically the Pulse analyzer tests. It's designed for evaluating Large Language Models (LLMs) on static analysis tasks, particularly memory safety bug detection in C code.

Note: This is an evaluation-only dataset. All examples are provided in the test split.

Key Features

  • 523 individual C functions with ground truth bug annotations
  • 51 unique source files from Infer's test suite
  • 5 bug categories: NULL pointer dereference, memory leak, use-after-free, uninitialized value, resource leak
  • Smart anonymization: Function names preserve semantic meaning while removing evaluation hints (_bad, _ok suffixes)
  • Multiple bugs per function: Some functions contain multiple bug types (2.5% of dataset)
  • Realistic code: Actual test cases from a production static analyzer

Dataset Statistics

  • Total examples: 523
  • With bugs: 217 (41.5%)
  • Safe (no bugs): 306 (58.5%)
  • Unique source files: 51

Bug Category Distribution

Category Count Percentage
safe 306 58.5%
nullptr_dereference 112 21.4%
other 68 13.0%
memory_leak 18 3.4%
uninitialized_value 12 2.3%
use_after_free 4 0.8%
resource_leak 3 0.6%

Dataset Structure

Each example contains:

  • id: Unique identifier
  • source_file: Original file in Infer test suite
  • original_function_name: Original name from Infer tests
  • anonymized_function_name: Name with hints removed (e.g., malloc_no_check_badmalloc_no_check)
  • function_code: Complete C function code
  • context: Unified context including:
    • #include statements
    • Struct, enum, and typedef definitions (with nested dependencies)
    • Global variable declarations
    • Dependency function implementations
  • has_bug: Boolean indicating if function has bugs
  • bug_types: List of bug types (NULLPTR_DEREFERENCE, MEMORY_LEAK, etc.)
  • bug_line_offsets: Line numbers relative to function start
  • bug_absolute_lines: Absolute line numbers in original file
  • bug_severities: Bug severity levels
  • bug_traces: Detailed trace information from Infer
  • category: Primary bug category or "safe"
  • requires_interprocedural: Whether analysis requires understanding function calls
  • start_line/end_line: Location in original source file

Example

from datasets import load_dataset

dataset = load_dataset("YOUR_USERNAME/infer-pulse-eval")

# Get first test example
example = dataset['test'][0]

print(f"Function: {example['anonymized_function_name']}")
print(f"Has bug: {example['has_bug']}")
if example['has_bug']:
    print(f"Bug types: {example['bug_types']}")
print(f"\nCode:\n{example['function_code']}")

Intended Use

This dataset is designed for:

  1. Evaluating LLMs on static analysis tasks
  2. Benchmarking bug detection capabilities
  3. Training models for code understanding
  4. Researching AI-assisted program analysis

Evaluation Protocol

Send the LLM:

  • System prompt with bug type definitions and analysis rules
  • User prompt with the function_code and the context (includes, types, globals, dependencies)

Expected LLM response format:

{
  "has_bug": true|false,
  "bugs": [
    {
      "type": "NULLPTR_DEREFERENCE",
      "line": 3,
      "explanation": "malloc can return NULL, dereferenced without check"
    }
  ]
}

Compare against ground truth has_bug and bug_types fields.

Anonymization Strategy

Function names are "anonymized" by removing evaluation hints while preserving semantic meaning:

  • Removed: _bad, _ok, _good, _latent suffixes, FP_, FN_ prefixes
  • Preserved: Descriptive parts (e.g., malloc_no_check, use_after_free_simple)

This maintains realistic code analysis conditions without giving away answers.

Data Source

All examples are extracted from Meta's Infer static analyzer:

License

MIT License (same as Infer project)

Citation

If you use this dataset, please cite:

@misc{{infer-pulse-eval-2024,
  title={{Infer Pulse Static Analysis Evaluation Dataset}},
  author={{Extracted from Meta's Infer project}},
  year={{2024}},
  url={{https://github.com/facebook/infer}}
}}

Contact

For questions or issues, please open an issue on the dataset repository.

Changelog

Version 1.0 (2024-11-08)

  • Initial release
  • 523 examples from 51 source files
  • Smart anonymization preserving semantic meaning
  • Multiple bugs per function support