Rust-twins: Automatic Rust Compiler Testing through Program Mutation and Dual Macros Generation

Rust is a relatively new programming language known for its memory safety and numerous advanced features. It has been widely used in system software in recent years. Thus, ensuring the reliability and robustness of the only implementation of the Rust compiler, rustc, is critical. However, compiler t...

Full description

Saved in:
Bibliographic Details
Published inIEEE/ACM International Conference on Automated Software Engineering : [proceedings] pp. 631 - 642
Main Authors Yang, Wenzhang, Gao, Cuifeng, Liu, Xiaoyuan, Li, Yuekang, Xue, Yinxing
Format Conference Proceeding
LanguageEnglish
Published ACM 27.10.2024
Subjects
Online AccessGet full text
ISSN2643-1572
DOI10.1145/3691620.3695059

Cover

Abstract Rust is a relatively new programming language known for its memory safety and numerous advanced features. It has been widely used in system software in recent years. Thus, ensuring the reliability and robustness of the only implementation of the Rust compiler, rustc, is critical. However, compiler testing, as one of the most effective techniques to detect bugs, faces difficulties in generating valid Rust programs with sufficient diversity due to its stringent memory safety mechanisms. Furthermore, existing research primarily focuses on testing rustc to trigger crash errors, neglecting incorrect compilation results - miscompilation. Detecting miscompilation remains a challenge in the absence of multiple implementations of the Rust compiler to serve as a test oracle.This paper tackles these challenges by introducing rust-twins, a novel and effective approach to performing automated differential testing for rustc to detect both crashes and miscompilations. We devise four Rust-specific mutators and adapt fourteen general mutators for Rust, each intends to produce a syntax and semantic valid Rust program to trigger rustc crashes. Additionally, we develop a macroize approach to rewrite a regular Rust program into dual macros with equivalent behaviors but in different implementations. Furthermore, we design an assessment component to check the equivalence by comparing the expansion results with a simple macro input. Finally, rust-twins attempts to expand the two macros with numerous complex inputs to detect differences. Due to the macro expansion mechanism, the root causes of differences can arise not only from the macro expansion part but also from any other mis-implemented compiler code.We have evaluated rust-twins on the latest version of rustc. Our experimental results indicate that rust-twins achieves twice the total line coverage and identifies more crashes and differences than the best baseline technique, rustsmith, after 24 hours of testing. In total, rust-twins triggered 10 rustc crashes, and 229 of the generated macros exposed rustc differences. We analyzed and reported 12 previously unknown bugs, of which 8 have already been confirmed and fixed.
AbstractList Rust is a relatively new programming language known for its memory safety and numerous advanced features. It has been widely used in system software in recent years. Thus, ensuring the reliability and robustness of the only implementation of the Rust compiler, rustc, is critical. However, compiler testing, as one of the most effective techniques to detect bugs, faces difficulties in generating valid Rust programs with sufficient diversity due to its stringent memory safety mechanisms. Furthermore, existing research primarily focuses on testing rustc to trigger crash errors, neglecting incorrect compilation results - miscompilation. Detecting miscompilation remains a challenge in the absence of multiple implementations of the Rust compiler to serve as a test oracle.This paper tackles these challenges by introducing rust-twins, a novel and effective approach to performing automated differential testing for rustc to detect both crashes and miscompilations. We devise four Rust-specific mutators and adapt fourteen general mutators for Rust, each intends to produce a syntax and semantic valid Rust program to trigger rustc crashes. Additionally, we develop a macroize approach to rewrite a regular Rust program into dual macros with equivalent behaviors but in different implementations. Furthermore, we design an assessment component to check the equivalence by comparing the expansion results with a simple macro input. Finally, rust-twins attempts to expand the two macros with numerous complex inputs to detect differences. Due to the macro expansion mechanism, the root causes of differences can arise not only from the macro expansion part but also from any other mis-implemented compiler code.We have evaluated rust-twins on the latest version of rustc. Our experimental results indicate that rust-twins achieves twice the total line coverage and identifies more crashes and differences than the best baseline technique, rustsmith, after 24 hours of testing. In total, rust-twins triggered 10 rustc crashes, and 229 of the generated macros exposed rustc differences. We analyzed and reported 12 previously unknown bugs, of which 8 have already been confirmed and fixed.
Author Liu, Xiaoyuan
Xue, Yinxing
Gao, Cuifeng
Yang, Wenzhang
Li, Yuekang
Author_xml – sequence: 1
  givenname: Wenzhang
  surname: Yang
  fullname: Yang, Wenzhang
  email: yywwzz@mail.ustc.edu.cn
  organization: University of Science and Technology of China,Anhui,China
– sequence: 2
  givenname: Cuifeng
  surname: Gao
  fullname: Gao, Cuifeng
  email: gcf20225162@mail.ustc.edu.cn
  organization: University of Science and Technology of China,Anhui,China
– sequence: 3
  givenname: Xiaoyuan
  surname: Liu
  fullname: Liu, Xiaoyuan
  email: lxyyyy@mail.ustc.edu.cn
  organization: University of Science and Technology of China,Anhui,China
– sequence: 4
  givenname: Yuekang
  surname: Li
  fullname: Li, Yuekang
  email: yuekang.li@unsw.edu.au
  organization: University of New South Wales,Sydney,Australian
– sequence: 5
  givenname: Yinxing
  surname: Xue
  fullname: Xue, Yinxing
  email: yxxue@ustc.edu.cn
  organization: University of Science and Technology of China,Anhui,China
BookMark eNotjstOwzAURA0CiVK6ZsPCP5Di61didlV5Sq1AqKwrx7lpLTVxZTtC_D3hsTqjmdFoLslZH3ok5BrYHECqW6ENaM7mIxVT5oTMTGkqyVgJXFblKZlwLUUBquQXZJaSr9kolQbQE7J9H1Iu8qfv0x1dDDl0NntHf1y6DN3RHzDSDabs-x3N-xiG3Z6-xbCLtqPrIY_t0FPbN_R-sAe6ti6GRJ-wx_gbXZHz1h4Szv45JR-PD5vlc7F6fXpZLlaFHT_morUWObcoDZTY1mCtQWAtc41SgjtdaWwdMKgdqytssEJTM9kIB1hJYExMyc3frkfE7TH6zsavLbBSS1MK8Q33SlgN
CODEN IEEPAD
ContentType Conference Proceeding
DBID 6IE
6IL
CBEJK
RIE
RIL
DOI 10.1145/3691620.3695059
DatabaseName IEEE Electronic Library (IEL) Conference Proceedings
IEEE Xplore POP ALL
IEEE Xplore All Conference Proceedings
IEEE Electronic Library (IEL)
IEEE Proceedings Order Plans (POP All) 1998-Present
DatabaseTitleList
Database_xml – sequence: 1
  dbid: RIE
  name: IEEE Xplore Digital Libary (IEL)
  url: https://proxy.k.utb.cz/login?url=https://ieeexplore.ieee.org/
  sourceTypes: Publisher
DeliveryMethod fulltext_linktorsrc
Discipline Computer Science
EISBN 9798400712487
EISSN 2643-1572
EndPage 642
ExternalDocumentID 10764973
Genre orig-research
GroupedDBID 6IE
6IF
6IH
6IK
6IL
6IM
6IN
6J9
AAJGR
AAWTH
ABLEC
ACREN
ADYOE
ADZIZ
AFYQB
ALMA_UNASSIGNED_HOLDINGS
AMTXH
BEFXN
BFFAM
BGNUA
BKEBE
BPEOZ
CBEJK
CHZPO
IEGSK
IPLJI
M43
OCL
RIE
RIL
ID FETCH-LOGICAL-a248t-faae22ae4917efb1aa9e10f0cd5532c686efc101bc0b8ede8e9b04d3c1e841003
IEDL.DBID RIE
IngestDate Wed Jan 15 06:20:43 EST 2025
IsPeerReviewed false
IsScholarly true
Language English
LinkModel DirectLink
MergedId FETCHMERGED-LOGICAL-a248t-faae22ae4917efb1aa9e10f0cd5532c686efc101bc0b8ede8e9b04d3c1e841003
PageCount 12
ParticipantIDs ieee_primary_10764973
PublicationCentury 2000
PublicationDate 2024-Oct.-27
PublicationDateYYYYMMDD 2024-10-27
PublicationDate_xml – month: 10
  year: 2024
  text: 2024-Oct.-27
  day: 27
PublicationDecade 2020
PublicationTitle IEEE/ACM International Conference on Automated Software Engineering : [proceedings]
PublicationTitleAbbrev ASE
PublicationYear 2024
Publisher ACM
Publisher_xml – name: ACM
SSID ssib057256116
ssj0051577
Score 2.2854247
Snippet Rust is a relatively new programming language known for its memory safety and numerous advanced features. It has been widely used in system software in recent...
SourceID ieee
SourceType Publisher
StartPage 631
SubjectTerms Compiler Testing
Computer bugs
Differential Testing
Faces
Program processors
Robustness
Rust
Safety
Semantics
Software engineering
Software reliability
Syntactics
Testing
Title Rust-twins: Automatic Rust Compiler Testing through Program Mutation and Dual Macros Generation
URI https://ieeexplore.ieee.org/document/10764973
hasFullText 1
inHoldings 1
isFullTextHit
isPrint
link http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwjV1bS8MwFA5uTz7Ny8Q7efC1M0mTNvVN1DGEDZEN9jZyORFROtlaBH-9SdqpCIJvJS0hpDnn-5Kc8x2ELixNHdHeAJ0mKuEWbKIdiETn1lEFUqYmBshOstGM38_FvE1Wj7kwABCDz2AQHuNdvl2aOhyVeQvPM17kaQd1_DprkrU2i0fkHrxp4DqNG_Y4neetlg_l4jLNPBFifo-aFSIqk_4ophKxZNhDk80omhCSl0Fd6YH5-CXQ-O9h7qD-d9oefvgCpF20BeUe6m3qNuDWjPfR4rFeV0n1_lyur_B1XS2jbCsOrTh87R3FCk-D_Eb5hNtCPqHjEMiFx3VzeY9VafFtrV7xWAWoxY2AdXjVR7Ph3fRmlLSFFhLFuKwSpxQwpoD7vRs4TZUqgBJHjBUiZSaTGTjjbVcboiVYkFBowm1qKEhOvV84QN1yWcIhwoymYCxJnZaGO-f5uyBKK-GEKbQw_Aj1w4Qt3hotjcVmro7_aD9B28zTiIAWLD9F3WpVw5mnAZU-j7__E_W4tJE
linkProvider IEEE
linkToHtml http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwjV1bS8MwFA46H_RpXibezYOvnU2btKlvoo6p2xDZYG8jlxMRpZOtRfDXm6StiiD4VtIQQsg535fknO8gdKZJbEJpDdDIUARUgw6kARbIVBsigPNY-QDZUdKf0Lspm9bJ6j4XBgB88Bl03ad_y9dzVbqrMmvhaUKzNF5Faxb4KavStZrtw1IL38SxncoRW6RO01rNh1B2HieWCkX2lJpkzGuT_iin4tGk10ajZh5VEMlLtyxkV338kmj890Q3Uec7cQ8_fEHSFlqBfBu1m8oNuDbkHTR7LJdFULw_58sLfFkWcy_cil0rdr2tq1jgsRPgyJ9wXcrHDexCufCwrJ7vscg1vi7FKx4KB7a4krB2vzpo0rsZX_WDutRCICLKi8AIAVEkgNrTGxhJhMiAhCZUmrE4UglPwChrvVKFkoMGDpkMqY4VAU6J9Qy7qJXPc9hDOCIxKB3GRnJFjbEMnoVCCmaYyiRTdB913ILN3io1jVmzVgd_tJ-i9f54OJgNbkf3h2gjsqTCYUeUHqFWsSjh2JKCQp74rfAJltq33g
openUrl ctx_ver=Z39.88-2004&ctx_enc=info%3Aofi%2Fenc%3AUTF-8&rfr_id=info%3Asid%2Fsummon.serialssolutions.com&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=proceeding&rft.title=IEEE%2FACM+International+Conference+on+Automated+Software+Engineering+%3A+%5Bproceedings%5D&rft.atitle=Rust-twins%3A+Automatic+Rust+Compiler+Testing+through+Program+Mutation+and+Dual+Macros+Generation&rft.au=Yang%2C+Wenzhang&rft.au=Gao%2C+Cuifeng&rft.au=Liu%2C+Xiaoyuan&rft.au=Li%2C+Yuekang&rft.date=2024-10-27&rft.pub=ACM&rft.eissn=2643-1572&rft.spage=631&rft.epage=642&rft_id=info:doi/10.1145%2F3691620.3695059&rft.externalDocID=10764973