SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2501.14257 · 2025

C2SaferRust: Transforming C Projects into Safer Rust with NeuroSymbolic Techniques

arXiv · PDF · Open in the Atlas

Code that ran

8 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 8 have no contract verdict; 0 failures of our instrument; 0 no recorded run), measured 2026-11-24; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2501.14257.json · badge: /api/ran/2501.14257.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
vikramnitin9/c2saferrust canonical (classifier label)
classifier basis not recorded on the link
8 ran · 0 no recorded run
FunctionStatusWhere it lives
extract_c_body Ran
ran on a synthesized input
vikramnitin9/c2saferrust/translate.py
code served (permissive licence) · get_code("1d94d751f4d76725")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
from pathlib import Path
import tempfile

# Create a temporary directory with a test C file
temp_dir = tempfile.mkdtemp()
test_c_file = os.path.join(temp_dir, "test.c")

# Write a sample C file with enough lines to test the extraction
c_code_content = """#include <stdio.h>

int add(int a, int b) {
    int result = a + b;
    return result;
}

void hello() {
    printf("Hello World");
}
"""

with open(test_c_file, 'w') as f:
    f.write(c_code_content)

# Create the func dictionary with line/column information
# The 'add' function starts at line 3, column 1 and ends at line 6, column 1
func = {
    'filename': 'test.c',
    'startLine': 3,
    'startCol': 1,
    'endLine': 6,
    'endCol': 1
}

ARGS = {
    'func': func,
    'c_code_dir': temp_dir
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_metrics_output Ran
ran on a synthesized input
vikramnitin9/c2saferrust/coreutils/collect_results.py
code served (permissive licence) · get_code("d8a02a7d5d17fad5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def parse_metrics_output(metrics_output):
    metrics = {}
    for line in metrics_output.split('\n'):
        unsafe_spans = re.match('Unsafe lines: (\\d+)', line)
        if unsafe_spans:
            if 'unsafe_spans' in metrics:
                metrics['unsafe_spans'] += int(unsafe_spans.group(1))
            else:
                metrics['unsafe_spans'] = int(unsafe_spans.group(1))
        unsafe_calls = re.match('Unsafe calls: (\\d+)', line)
        if unsafe_calls:
            if 'unsafe_calls' in metrics:
                metrics['unsafe_calls'] += int(unsafe_calls.group(1))
            else:
                metrics['unsafe_calls'] = int(unsafe_calls.group(1))
        unsafe_casts = re.match('Unsafe lines: (\\d+)', line)
        if unsafe_casts:
            if 'unsafe_casts' in metrics:
                metrics['unsafe_casts'] += int(unsafe_casts.group(1))
            else:
                metrics['unsafe_casts'] = int(unsafe_casts.group(1))
        raw_pointer_derefs = re.match('Raw pointer dereferences: (\\d+)', line)
        if raw_pointer_derefs:
            if 'raw_pointer_derefs' in metrics:
                metrics['raw_pointer_derefs'] += int(raw_pointer_derefs.group(1))
            else:
                metrics['raw_pointer_derefs'] = int(raw_pointer_derefs.group(1))
        raw_pointer_decls = re.match('Raw pointer declarations: (\\d+)', line)
        if raw_pointer_decls:
            if 'raw_pointer_decls' in metrics:
                metrics['raw_pointer_decls'] += int(raw_pointer_decls.group(1))
            else:
                metrics['raw_pointer_decls'] = int(raw_pointer_decls.group(1))
    return metrics

metrics_output_text = """Unsafe lines: 5
Unsafe calls: 3
Raw pointer dereferences: 2
Raw pointer declarations: 1
Unsafe lines: 2
Raw pointer dereferences: 1"""

ARGS = {
    "metrics_output": metrics_output_text
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_metrics_output Ran
ran on a synthesized input
vikramnitin9/c2saferrust/laertes_benchmarks/collect_results.py
code served (permissive licence) · get_code("79669bd94b1bc427")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def parse_metrics_output(metrics_output):
    metrics = {}
    for line in metrics_output.split('\n'):
        unsafe_spans = re.match('Unsafe lines: (\\d+)', line)
        if unsafe_spans:
            if 'unsafe_spans' in metrics:
                metrics['unsafe_spans'] += int(unsafe_spans.group(1))
            else:
                metrics['unsafe_spans'] = int(unsafe_spans.group(1))
        unsafe_calls = re.match('Unsafe calls: (\\d+)', line)
        if unsafe_calls:
            if 'unsafe_calls' in metrics:
                metrics['unsafe_calls'] += int(unsafe_calls.group(1))
            else:
                metrics['unsafe_calls'] = int(unsafe_calls.group(1))
        unsafe_casts = re.match('Unsafe casts: (\\d+)', line)
        if unsafe_casts:
            if 'unsafe_casts' in metrics:
                metrics['unsafe_casts'] += int(unsafe_casts.group(1))
            else:
                metrics['unsafe_casts'] = int(unsafe_casts.group(1))
        raw_pointer_derefs = re.match('Raw pointer dereferences: (\\d+)', line)
        if raw_pointer_derefs:
            if 'raw_pointer_derefs' in metrics:
                metrics['raw_pointer_derefs'] += int(raw_pointer_derefs.group(1))
            else:
                metrics['raw_pointer_derefs'] = int(raw_pointer_derefs.group(1))
        raw_pointer_decls = re.match('Raw pointer declarations: (\\d+)', line)
        if raw_pointer_decls:
            if 'raw_pointer_decls' in metrics:
                metrics['raw_pointer_decls'] += int(raw_pointer_decls.group(1))
            else:
                metrics['raw_pointer_decls'] = int(raw_pointer_decls.group(1))
    return metrics

metrics_output = """Unsafe lines: 5
Unsafe calls: 3
Unsafe casts: 2
Raw pointer dereferences: 7
Raw pointer declarations: 4
Unsafe lines: 2
Unsafe calls: 1"""

ARGS = {
    "metrics_output": metrics_output
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_span Ran
ran on a synthesized input
vikramnitin9/c2saferrust/translate.py
code served (permissive licence) · get_code("8bb157526af53607")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# No imports needed - the function only uses string operations

# Construct a valid span string with the format:
# file_name:start_line:start_col:end_line:end_col optional_appendage
span = "example.py:10:5:15:20 extra_info"

ARGS = {
    'span': span
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
run Ran
ran on a synthesized input
vikramnitin9/c2saferrust/coreutils/collect_length_data.py
code served (permissive licence) · get_code("9062a16835c0b759")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import subprocess

def run(command):
    try:
        result = subprocess.run(command, shell=True, timeout=25, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
        if result.returncode != 0:
            exec_output = result.stderr.decode('utf-8')
            if exec_output.strip() == '':
                exec_output = result.stdout.decode('utf-8')
            raise RuntimeError(exec_output)
    except subprocess.TimeoutExpired:
        raise RuntimeError('Timeout')
    return result.stdout.decode('utf-8')


ARGS = {
    "command": "echo 'Hello World'"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
run Ran
ran on a synthesized input
vikramnitin9/c2saferrust/laertes_benchmarks/collect_results.py
code served (permissive licence) · get_code("6a6cd1894d410134")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import subprocess

# The function 'run' takes a single parameter 'command' which is a string
# representing a shell command to execute. It runs the command with a 120 second
# timeout and returns the stdout as a decoded string.

# We'll construct a simple valid command that succeeds
command = "echo 'Hello, World!'"

ARGS = {
    "command": command
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
safe_load_json Ran
ran on a synthesized input
vikramnitin9/c2saferrust/coreutils/get_covered_funcs.py
code served (permissive licence) · get_code("4d2f5ecfe221e6c0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import tempfile
import os

# Create a temporary JSON file for testing
temp_dir = tempfile.mkdtemp()
temp_filepath = os.path.join(temp_dir, "test.json")

# Write valid JSON content to the file
json_content = json.dumps([{"key": "value"}, {"number": 42}])
with open(temp_filepath, 'wb') as f:
    f.write(json_content.encode('latin-1'))

ARGS = {
    "filepath": temp_filepath
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
span_to_text Ran
ran on a synthesized input
vikramnitin9/c2saferrust/translate.py
code served (permissive licence) · get_code("042a98511f6d8505")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
from pathlib import Path

# Create a temporary directory with test files
temp_dir = tempfile.mkdtemp()
code_dir = Path(temp_dir)

# Create a test file with multiple lines
test_file = code_dir / "example.py"
test_content = """def hello():
    print("world")
    x = 42
    return x
"""
with open(test_file, 'w') as f:
    f.write(test_content)

# Create a span string in the format: filename:start_line:start_col:end_line:end_col [appendage]
# This span points to "print" on line 2, columns 5-10
span = "example.py:2:5:2:10"

ARGS = {
    'code_dir': str(code_dir),
    'span': span,
    'old': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 8 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

In recent years, there has been a lot of interest in converting C code to Rust, to benefit from the memory and thread safety guarantees of Rust. C2Rust is a rule-based system that can automatically convert C code to functionally identical Rust, but the Rust code that it produces is non-idiomatic, i.e., makes extensive use of unsafe Rust, a subset of the language that doesn't have memory or thread safety guarantees. At the other end of the spectrum are LLMs, which produce idiomatic Rust code, but these have the potential to make mistakes and are constrained in the length of code they can process. In this paper, we present C2SaferRust, a novel approach to translate C to Rust that combines the strengths of C2Rust and LLMs. We first use C2Rust to convert C code to non-idiomatic, unsafe Rust. We then decompose the unsafe Rust code into slices that can be individually translated to safer Rust by an LLM. After processing each slice, we run end-to-end test cases to verify that the code still functions as expected. We also contribute a benchmark of 7 real-world programs, translated from C to unsafe Rust using C2Rust. Each of these programs also comes with end-to-end test cases. On this benchmark, we are able to reduce the number of raw pointers by up to 38%, and reduce the amount of unsafe code by up to 28%, indicating an increase in safety. The resulting programs still pass all test cases. C2SaferRust also shows convincing gains in performance against two previous techniques for making Rust code safer.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2501.14257")
get_code_for_paper("2501.14257")
have("2501.14257")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2501.14257.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2501.14257.svg)](https://syntology.ai/paper/2501.14257)

Connect an agent — have() is free.