File size: 5,082 Bytes
c120ddf
435a0a9
 
 
 
 
 
 
 
 
 
 
 
 
 
c120ddf
435a0a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2240657
 
 
 
 
435a0a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2240657
435a0a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
---
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](https://fbinfer.com/) 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_bad` → `malloc_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

```python
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:
```json
{
  "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:
- Repository: https://github.com/facebook/infer
- Test suite: `infer/tests/codetoanalyze/c/pulse/`
- Ground truth: `issues.exp` file from Infer's test expectations

## License

MIT License (same as Infer project)

## Citation

If you use this dataset, please cite:

```bibtex
@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