{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/c2saferrust-transforming-c-projects-into","title":"C2SaferRust: Transforming C Projects into Safer Rust with NeuroSymbolic Techniques","arxiv_id":"2501.14257","date":"2025-01-24","proceeding":null,"authors":["Vikram Nitin","Rahul Krishna","Luiz Lemos do Valle","Baishakhi Ray"],"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.","url_abs":"https://arxiv.org/abs/2501.14257v1","url_pdf":"https://arxiv.org/pdf/2501.14257v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"links_only","authors_date_abstract":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license), from the Kaggle arXiv metadata snapshot of 2026-09-12"},"code_links":[{"paper_slug":"c2saferrust-transforming-c-projects-into","repo_url":"https://github.com/vikramnitin9/c2saferrust","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2501.14257","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2501.14257"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/vikramnitin9/c2saferrust","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":8},"by_repo_kind":{"official":{"samples":8,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"1d94d751f4d76725","entry":"extract_c_body","repo":"vikramnitin9/c2saferrust","repo_kind":"official","path":"translate.py","file_url":"https://github.com/vikramnitin9/c2saferrust/blob/HEAD/translate.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1d94d751f4d76725"}},{"code_sha256_prefix":"d8a02a7d5d17fad5","entry":"parse_metrics_output","repo":"vikramnitin9/c2saferrust","repo_kind":"official","path":"coreutils/collect_results.py","file_url":"https://github.com/vikramnitin9/c2saferrust/blob/HEAD/coreutils/collect_results.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d8a02a7d5d17fad5"}},{"code_sha256_prefix":"79669bd94b1bc427","entry":"parse_metrics_output","repo":"vikramnitin9/c2saferrust","repo_kind":"official","path":"laertes_benchmarks/collect_results.py","file_url":"https://github.com/vikramnitin9/c2saferrust/blob/HEAD/laertes_benchmarks/collect_results.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"79669bd94b1bc427"}},{"code_sha256_prefix":"8bb157526af53607","entry":"parse_span","repo":"vikramnitin9/c2saferrust","repo_kind":"official","path":"translate.py","file_url":"https://github.com/vikramnitin9/c2saferrust/blob/HEAD/translate.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8bb157526af53607"}},{"code_sha256_prefix":"9062a16835c0b759","entry":"run","repo":"vikramnitin9/c2saferrust","repo_kind":"official","path":"coreutils/collect_length_data.py","file_url":"https://github.com/vikramnitin9/c2saferrust/blob/HEAD/coreutils/collect_length_data.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9062a16835c0b759"}},{"code_sha256_prefix":"6a6cd1894d410134","entry":"run","repo":"vikramnitin9/c2saferrust","repo_kind":"official","path":"laertes_benchmarks/collect_results.py","file_url":"https://github.com/vikramnitin9/c2saferrust/blob/HEAD/laertes_benchmarks/collect_results.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6a6cd1894d410134"}},{"code_sha256_prefix":"4d2f5ecfe221e6c0","entry":"safe_load_json","repo":"vikramnitin9/c2saferrust","repo_kind":"official","path":"coreutils/get_covered_funcs.py","file_url":"https://github.com/vikramnitin9/c2saferrust/blob/HEAD/coreutils/get_covered_funcs.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4d2f5ecfe221e6c0"}},{"code_sha256_prefix":"042a98511f6d8505","entry":"span_to_text","repo":"vikramnitin9/c2saferrust","repo_kind":"official","path":"translate.py","file_url":"https://github.com/vikramnitin9/c2saferrust/blob/HEAD/translate.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"042a98511f6d8505"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}