Fractional Ownerships for Safe Memory Deallocation
2009, Lecture Notes in Computer Science
https://doi.org/10.1007/978-3-642-10672-9_11Abstract
We propose a type system for a programming language with memory allocation/deallocation primitives, which prevents memory-related errors such as double-frees and memory leaks. The main idea is to augment pointer types with fractional ownerships, which express both capabilities and obligations to access or deallocate memory cells. By assigning an ownership to each pointer type constructor (rather than to a variable), our type system can properly reason about list/tree-manipulating programs. Furthermore, thanks to the use of fractions as ownerships, the type system admits a polynomial-time type inference algorithm, which serves as an algorithm for automatic verification of lack of memoryrelated errors. A prototype verifier has been implemented and tested for C programs.
References (14)
- Boyland, J.: Checking interference with fractional permissions. In: Proceedings of SAS 2003. Volume 2694 of LNCS., Springer-Verlag (2003) 55-72
- Heine, D.L., Lam, M.S.: A practical flow-sensitive and context-sensitive C and C++ memory leak detector. In: Proc. of PLDI. (2003) 168-181
- Ueda, K.: Resource-passing concurrent programming. In: Proceedings of 4th In- ternational Symposium on Theoretical Aspects of Computer Science (TACS2001). Volume 2215 of LNCS., Springer-Verlag (2001) 95-126
- Suenaga, K., Kobayashi, N.: Fractional ownerships for safe memory deallocation. A longer version, available from http://www.kb.ecei.tohoku.ac.jp/~koba/papers/ malloc.pdf (2009)
- Dor, N., Rodeh, M., Sagiv, S.: Checking cleanness in linked lists. In: Proceedings of SAS 2000. Volume 1824 of LNCS., Springer-Verlag (2000) 115-134
- Orlovich, M., Rugina, R.: Memory leak analysis by contradiction. In: Proceedings of SAS 2006. Volume 4134 of LNCS., Springer-Verlag (2006) 405-424
- Xie, Y., Aiken, A.: Context-and path-sensitive memory leak detection. In: ACM SIGSOFT International Symposium on Foundations of Software Engineer- ing. (2005) 115-125
- Boyapati, C., Salcianu, A., Beebee, W.S., Rinard, M.C.: Ownership types for safe region-based memory management in real-time Java. In: Proc. of PLDI. (2003) 324-337
- Swamy, N., Hicks, M.W., Morrisett, G., Grossman, D., Jim, T.: Safe manual memory management in Cyclone. Sci. Comput. Program. 62(2) (2006) 122-144
- Yang, H., Lee, O., Berdine, J., Calcagno, C., Cook, B., Distefano, D., O'Hearn, P.W.: Scalable shape analysis for systems code. In: Proceedings of CAV 2008. Volume 5123 of LNCS., Springer-Verlag (2008) 385-398
- Berdine, J., Calcagno, C., Cook, B., Distefano, D., O'Hearn, P.W., Wies, T., Yang, H.: Shape analysis for composite data structures. In: Proceedings of CAV 2007. Volume 4590 of LNCS., Springer-Verlag (2007) 178-192
- Terauchi, T.: Checking race freedom via linear programming. In: Proc. of PLDI. (2008) 1-10
- Terauchi, T., Aiken, A.: A capability calculus for concurrency and determinism. ACM Trans. Prog. Lang. Syst. 30(5) (2008)
- Boyland, J.: Semantics of fractional permissions with nesting. UWM EECS Tech- nical Report CS-07-01 (2007)