20-CS-4003-001 Organization of Programming Languages Fall 2017
Code Safety

Lambda calculus, Type theory, Formal semantics, Program analysis

All lectures
Type, Memory, Thread Unsafe Code Examples

safety.tar     Archive. package containing all source code below plus the Makefile
 
type-unsafe-1.c     Type unsafe. operator works on string but a number is passed. Result is a segmentation fault.
 
type-unsafe-2.c     Type unsafe. memcpy is type oblivious, allows larger array to overwrite smaller array plus some space it should not be allowed to touch.
 
memory-unsafe-3.cc     Memory unsafe. dereference a null pointer.
 
memory_unsafe_4.java     Memory safety helper. Java uses exceptions to recover from dereferencing a null pointer.
 
memory-unsafe-5.cc     Memory unsafe. reference to an object exceeds the lifetime of that object.
 
memory-unsafe-6.cc     Memory unsafe. allow reference to a private variable.
 
memory-unsafe-9.c     Memory unsafe. overwrite the stack to execute malware (function g).
 
thread-unsafe-1.cc     Thread unsafe. dot product of two vectors is distributed over 8 threads but they interfere with each other and the final sum is wrong.
 
thread-safe-1.cc     Thread safe. above is fixed with mutex protecting incremental sum.
 
thread-safe-2.cc     Thread safe. local sum is added to global sum with mutex protection.
 
thread-safe-3.cc     Thread safe. protection from atomic assignment provided in hardware.
 
thread_unsafe_7.java     Thread unsafe. method used by multiple threads at the same time has problems.
 
truncation.cc     truncation. bypass security check because an int becomes a short.
 
binsearch-unsafe.cc     binary search. sum to get index variable in classic binary search may overflow.
 
binsearch-safe.cc     binary search. sum to get index variable in binary search does not overflow.
 
Makefile