依赖类型保持的内存分配
Dependent-Type-Preserving Memory Allocation
AI总结:
针对依赖类型语言编译后规范被擦除导致外部链接程序可违反内存安全的问题,提出支持依赖内存分配的类型化中间语言及依赖类型保持的编译通行证,以实现链接时类型检查。
摘要:
依赖类型编程语言(如 Coq、Agda、Idris 和 F*)允许程序员编写其程序的详细规范,并证明其程序满足这些规范。然而,这些规范在编译过程中可能被违反,因为它们在类型检查后被擦除。与编译后程序链接的外部程序可能违反原始程序的规范并改变编译后程序的行为——即使使用经过验证的编译器进行编译也是如此。例如,由于 Coq 不允许显式分配内存,程序员可能会将其 Coq 程序与一个可以分配内存的 C 程序链接。即使 Coq 程序使用经过验证的编译器编译,外部 C 程序仍然可以通过提供未初始化的内存指针来违反 Coq 程序的内存安全规范。这种错误可以通过在一种足够表达内存是否已初始化与未初始化的语言中进行类型检查来排除。与具有未初始化指针的程序链接可以被视为类型错误,而我们的链接过程可以防止与类型错误的程序链接。为了在链接期间促进类型检查,我们可以使用类型保持编译,该编译在编译过程中保留类型。在这项正在进行的工作中,我们开发了一种支持依赖内存分配的类型化中间语言,以及一个用于内存分配的依赖类型保持编译器通行证。
英文摘要:
Dependently typed programming languages such as Coq, Agda, Idris, and F*, allow programmers to write detailed specifications of their programs and prove their programs meet these specifications. However, these specifications can be violated during compilation since they are erased after type checking. External programs linked with the compiled program can violate the specifications of the original program and change the behavior of the compiled program -- even when compiled with a verified compiler. For example, since Coq does not allow explicitly allocating memory, a programmer might link their Coq program with a C program that can allocate memory. Even if the Coq program is compiled with a verified compiler, the external C program can still violate the memory-safe specification of the Coq program by providing an uninitialized pointer to memory. This error could be ruled out by type checking in a language expressive enough to indicate whether memory is initialized versus uninitialized. Linking with a program with an uninitialized pointer could be considered ill-typed, and our linking process could prevent linking with ill-typed programs. To facilitate type checking during linking, we can use type-preserving compilation, which preserves the types through the compilation process. In this ongoing work, we develop a typed intermediate language that supports dependent memory allocation, as well as a dependent-type-preserving compiler pass for memory allocation.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。