JUSTGen: Effective Test Generation for Unspecified JNI Behaviors on JVMs

Sungjae Hwang, Sungho Lee, Jihoon Kim, Sukyoung Ryu
{"title":"JUSTGen: Effective Test Generation for Unspecified JNI Behaviors on JVMs","authors":"Sungjae Hwang, Sungho Lee, Jihoon Kim, Sukyoung Ryu","doi":"10.1109/ICSE-Companion52605.2021.00073","DOIUrl":null,"url":null,"abstract":"Java Native Interface (JNI) provides a way for Java applications to access native libraries, but it is difficult to develop correct JNI programs. By leveraging native code, the JNI enables Java developers to implement efficient applications and to reuse code written in other programming languages such as C and C++. Besides, the core Java libraries already use the JNI to provide system features like a graphical user interface. As a result, many mainstream Java Virtual Machines (JVMs) support the JNI. However, due to the complex interoperation semantics between different programming languages, implementing correct JNI programs is not trivial. Moreover, because of the performance overhead, JVMs do not validate erroneous JNI interoperations by default, but they validate them only when the debug feature, the -Xcheck:jni option, is enabled. Therefore, the correctness of JNI programs highly relies on the checks by the -Xcheck:jni option of JVMs. Questions remain, however, on the quality of the checks provided by the feature. Are there any properties that the -Xcheck:jni option fails to validate? If so, what potential issues can arise due to the lack of such validation? To the best of our knowledge, no research has explored these questions in-depth. In this paper, we empirically study the validation quality and impacts of the -Xcheck:jni option on mainstream JVMs using unspecified corner cases in the JNI specification. Such unspecified cases may lead to unexpected run-time behaviors because their semantics is not defined in the specification. For a systematic study, we propose JUSTGEN, a semi-automated approach to identify unspecified cases from a specification and generate test programs. JUSTGEN receives the JNI specification written in our domain specific language (DSL), and automatically discovers unspecified cases using an SMT solver. It then generates test programs that trigger the behaviors of unspecified cases. Using the generated tests, we empirically study the validation ability of the -Xcheck:jni option. Our experimental result shows that the JNI debug feature does not validate thousands of unspecified cases on JVMs, and they can cause critical run-time errors such as violation of the Java type system and memory corruption. We reported 792 unspecified cases that are not validated by JVMs to their corresponding JVM vendors. Among them, 563 cases have been fixed and the remaining cases will be fixed in near future. Based on our empirical study, we believe that the JNI specification should specify the semantics of the missing cases clearly and the debug feature should be supported completely.","PeriodicalId":136929,"journal":{"name":"2021 IEEE/ACM 43rd International Conference on Software Engineering: Companion Proceedings (ICSE-Companion)","volume":null,"pages":null},"PeriodicalIF":0.0000,"publicationDate":"2021-05-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"1","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"2021 IEEE/ACM 43rd International Conference on Software Engineering: Companion Proceedings (ICSE-Companion)","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1109/ICSE-Companion52605.2021.00073","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 1

Abstract

Java Native Interface (JNI) provides a way for Java applications to access native libraries, but it is difficult to develop correct JNI programs. By leveraging native code, the JNI enables Java developers to implement efficient applications and to reuse code written in other programming languages such as C and C++. Besides, the core Java libraries already use the JNI to provide system features like a graphical user interface. As a result, many mainstream Java Virtual Machines (JVMs) support the JNI. However, due to the complex interoperation semantics between different programming languages, implementing correct JNI programs is not trivial. Moreover, because of the performance overhead, JVMs do not validate erroneous JNI interoperations by default, but they validate them only when the debug feature, the -Xcheck:jni option, is enabled. Therefore, the correctness of JNI programs highly relies on the checks by the -Xcheck:jni option of JVMs. Questions remain, however, on the quality of the checks provided by the feature. Are there any properties that the -Xcheck:jni option fails to validate? If so, what potential issues can arise due to the lack of such validation? To the best of our knowledge, no research has explored these questions in-depth. In this paper, we empirically study the validation quality and impacts of the -Xcheck:jni option on mainstream JVMs using unspecified corner cases in the JNI specification. Such unspecified cases may lead to unexpected run-time behaviors because their semantics is not defined in the specification. For a systematic study, we propose JUSTGEN, a semi-automated approach to identify unspecified cases from a specification and generate test programs. JUSTGEN receives the JNI specification written in our domain specific language (DSL), and automatically discovers unspecified cases using an SMT solver. It then generates test programs that trigger the behaviors of unspecified cases. Using the generated tests, we empirically study the validation ability of the -Xcheck:jni option. Our experimental result shows that the JNI debug feature does not validate thousands of unspecified cases on JVMs, and they can cause critical run-time errors such as violation of the Java type system and memory corruption. We reported 792 unspecified cases that are not validated by JVMs to their corresponding JVM vendors. Among them, 563 cases have been fixed and the remaining cases will be fixed in near future. Based on our empirical study, we believe that the JNI specification should specify the semantics of the missing cases clearly and the debug feature should be supported completely.
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
jusgen:为jvm上未指定的JNI行为生成有效的测试
Java本机接口(Java Native Interface, JNI)为Java应用程序提供了访问本机库的方法,但是很难开发正确的JNI程序。通过利用本机代码,JNI使Java开发人员能够实现高效的应用程序,并重用用其他编程语言(如C和c++)编写的代码。此外,核心Java库已经使用JNI来提供图形用户界面等系统特性。因此,许多主流的Java虚拟机(jvm)都支持JNI。然而,由于不同编程语言之间复杂的互操作语义,实现正确的JNI程序并非易事。此外,由于性能开销,jvm默认情况下不会验证错误的JNI互操作,但只有在启用调试特性(-Xcheck: JNI选项)时才会验证它们。因此,JNI程序的正确性高度依赖于jvm的-Xcheck: JNI选项的检查。然而,该功能提供的检查质量仍然存在问题。是否有任何属性-Xcheck:jni选项无法验证?如果是这样,由于缺乏这样的验证,可能会出现哪些潜在的问题?据我们所知,还没有研究深入探讨过这些问题。在本文中,我们使用jni规范中未指定的角落案例,实证地研究了-Xcheck:jni选项对主流jvm的验证质量和影响。这种未指定的情况可能导致意外的运行时行为,因为它们的语义没有在规范中定义。对于系统的研究,我们提出JUSTGEN,这是一种半自动化的方法,用于从规范中识别未指定的案例并生成测试程序。JUSTGEN接收用我们的领域特定语言(DSL)编写的JNI规范,并使用SMT求解器自动发现未指定的情况。然后,它生成触发未指定情况的行为的测试程序。使用生成的测试,我们经验地研究了-Xcheck:jni选项的验证能力。我们的实验结果表明,JNI调试特性不能验证jvm上数千种未指定的情况,并且它们可能导致严重的运行时错误,例如违反Java类型系统和内存损坏。我们向相应的JVM供应商报告了792个未被JVM验证的未指定案例。其中563个案件已经确定,其余案件将在近期确定。根据我们的实证研究,我们认为JNI规范应该清楚地指定缺失用例的语义,并且应该完全支持调试特性。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 去求助
来源期刊
自引率
0.00%
发文量
0
期刊最新文献
Artifact Evaluation Program Committee Doctoral Symposium Program Committee Posters Program Committee CodeShovel: A Reusable and Available Tool for Extracting Source Code Histories Replication Package for Article: Data-Oriented Differential Testing of Object-Relational Mapping Systems
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1