COS 598E:Foundations of Language-Based Security



Homework 2

Due: Monday, March 4, 2002.

1.  Read the following two Cyclone papers. 

a) Cyclone: A Safe Dialect of C, Trevor Jim, Greg Morrisett, Dan Grossman, Michael Hicks, James Cheney, and Yanling Wang.  June, 2002.

b) Region-based Memory Management in Cyclone, Dan Grossman, Greg Morrisett, Trevor Jim, Michael Hicks, Yanling Wang, and James Cheney. June, 2002.

2.  Consider adding some concurrency features to TAL-5 (with tuples and a heap logic for managing the store).

a) Give types for the following three code labels

fork: requires a function pointer f (of no arguments) in register r1.  Suspends the current thread and begins executing f in a new thread with an empty stack.

exit: requires no arguments.  Terminates the current thread.  The stack must be empty.

yield: requires a function pointer f (of no arguments) in register r1.  Suspend the current thread.

b) Extend TAL machine states so that a machine state includes managed and unmanaged heaps which are shared between all threads, a register file which is shared and a list of threads.  Each thread is a pair of a stack and a block of code to be executed next.  Give typing rules for threads and machine states.

c) Give operational rules for fork, exit and yield.

d) Prove type preservation for the new concurrency primitives.

3.  In this problem, we will explore a proof technique originated by Karl Crary [ICFP 99] that can be used to show that our callee-saves calling convention is correct when functions are properly polymorphically typed.  We will carry out this proof in TAL-2 with polymorphism (the proof technique will scale easily to the full language).  The first step is to add singleton types to language and show that the language is still sound.

a) Add a typing rule to TAL-2 that will give any integer (i) a singleton type S(i).

b) State and prove the canonical forms lemma for singletons.

c) Check that type preservation and progress lemmas continue to be valid (don't hand anything in for this part).

d) Assume L,L' have the following types

L : ALL [a].  {r1:a,r31:{r1:a}}

L' : {r1:S(3)}

Let P = (H,{r1=3,r31=L'},jmp L[S(3)]) where H is a well formed heap containing L and L' with the types above.  Prove that if P ->* (H,R,jmp L') then R(r1) = 3.