Abstract
It is difficult to write programs that behave correctly in the presence of exceptions. We describe a dataflow analysis for finding a certain class of mistakes made while programs handle exceptions. These mistakes involve resource leaks and failures to restore program-specific invariants. Using this analysis we have found over 1,200 bugs in 4 million lines of Java. We give some evidence of the importance of the bugs we found and use them to highlight some limitations of destructors and finalizers. We propose and evaluate a new language feature, the compensation stack, to make it easier to write solid code in the presence of exceptions. These compensation stacks track obligations and invariants at run-time. Two case studies demonstrate that they can yield more natural source code and more consistent behavior in long-running programs.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Candea, G., Delgado, M., Chen, M., Fox, A.: Automatic failure-path inference: A generic introspection technique for internet applications. In: IEEE Workshop on Internet Applications, San Jose, California (2003)
Fu, C., Ryder, B., Milanova, A., Wannacott, D.: Testing of java web services for robustness. In: International Symposium on Software Testing and Analysis (2004)
Goodenough, J.B.: Exception handling: issues and a proposed notation. Communications of the ACM 18, 683–696 (1975)
Weimer, W., Necula, G.C.: Finding and preventing run-time error handling mistakes. In: Object-oriented programming, systems, languages, and applications, pp. 419–431 (2004)
Brown, A., Patterson, D.: Undo for operators: Building an undoable e-mail store. In: USENIX Annual Technical Conference (2003)
Engler, D., Chelf, B., Chou, A., Hallem, S.: Checking system rules using system-specific, programmer-written compiler extensions. In: Operating Systems Design and Implementation (2000)
Das, M., Lerner, S., Seigle, M.: ESP: path-sensitive program verification in polynomial time. SIGPLAN Notices 37, 57–68 (2002)
Ball, T., Rajamani, S.K.: Automatically validating temporal safety properties of interfaces. In: Dwyer, M.B. (ed.) SPIN 2001. LNCS, vol. 2057, pp. 103–122. Springer, Heidelberg (2001)
Chen, H., Dean, D., Wagner, D.: Model checking one million lines of C code. In: Network and Distributed System Security Symposium, San Diego, CA (2004)
Kildall, G.A.: A unified approach to global program optimization. In: Principles of Programming Languages, pp. 194–206. ACM Press, New York (1973)
DeLine, R., Fähndrich, M.: Enforcing high-level protocols in low-level software. In: Programming Language Design and Implementation, pp. 59–69 (2001)
Kremenek, T., Ashcraft, K., Yang, J., Engler, D.: Correlation exploitation in error ranking. In: Foundations of software engineering, pp. 83–93 (2004)
Weimer, W., Necula, G.C.: Mining Temporal Specifications for Error Detection. In: Halbwachs, N., Zuck, L.D. (eds.) TACAS 2005. LNCS, vol. 3440, pp. 461–476. Springer, Heidelberg (2005)
Gay, D., Aiken, A.: Memory management with explicit regions. In: Programming Language Design and Implementation, pp. 313–323 (1998)
O’Hanley, J.: Always close streams (2005), http://www.javapractices.com/
Boehm, H.J.: Destructors, finalizers and synchronization. In: Principles of Programming Languages. ACM Press, New York (2003)
Korth, H.F., Levy, E., Silberschatz, A.: A formal approach to recovery by compensating transactions. The VLDB Journal, 95–106 (1990)
Alonso, G., Kamath, M., Agrawal, D., Abbadi, A.E., Gunthor, R., Mohan, C.: Failure handling in large-scale workflow management systems. Technical Report RJ9913, IBM Almaden Research Center, San Jose, CA (1994)
Odersky, M., Wadler, P.: Pizza into Java: Translating theory into practice. In: Principles of Programming Languages, pp. 146–159 (1997)
Alonso, G., Hagen, C., Agrawal, D., Abbadi, A.E., Mohan, C.: Enhancing the fault tolerance of workflow management systems. IEEE Concurrency 8, 74–81 (2000)
Sun Microsystems: Java pet store 1.1.2 blueprint application (2001), http://java.sun.com/blueprints/code/
Chen, M.Y., Kiciman, E., Fratkin, E., Fox, A., Brewer, E.: Pinpoint: Problem determination in large, dynamic Internet services. In: International Conference on Dependable Systems and Networks, pp. 595–604. IEEE Computer Society, Los Alamitos (2002)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2006 Springer-Verlag Berlin Heidelberg
About this chapter
Cite this chapter
Weimer, W. (2006). Exception-Handling Bugs in Java and a Language Extension to Avoid Them. In: Dony, C., Knudsen, J.L., Romanovsky, A., Tripathi, A. (eds) Advanced Topics in Exception Handling Techniques. Lecture Notes in Computer Science, vol 4119. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11818502_2
Download citation
DOI: https://doi.org/10.1007/11818502_2
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-37443-5
Online ISBN: 978-3-540-37445-9
eBook Packages: Computer ScienceComputer Science (R0)