skip to main content
10.1145/512950.512963acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
Article
Free Access

Implementation of an array bound checker

Published:01 January 1977Publication History

ABSTRACT

This paper describes a system which checks correctness of array accesses automatically without any inductive assertions or human interaction. For each array access in the program a condition that the subscript is greater than or equal to the lower bound and a condition that the subscript is smaller than or equal to the upper bound are checked and the results indicating within the bound, out of bound, or undetermined are produced. It can check ordinary programs at about fifty lines per ten seconds, and it shows linear time complexity behavior.It has been long discussed whether program verification will ever become practical. The main argument against program verification is that it is very hard for a programmer to write assertions about programs. Even if he can supply enough assertions, he must have some knowledge about logic in order to prove the lemmas (or verification conditions) obtained from the verifier.However, there are some assertions about programs which must always be true no matter what the programs do; and yet which cannot be checked for all cases. These assertions include: integer values do not overflow, array subscripts are within range, pointers do not fall off NIL, cells are not reclaimed if they are still pointed to, uninitialized variables are not used.Since these conditions cannot be completely checked, many compilers produce dynamic checking code so that if the condition fails, then the program terminates with proper diagnostics. These dynamic checking code sometimes take up much computation time. It is better to have some checking so that unexpected overwriting of data will not occur, but it is still very awkward that the computation stops because of error. Moreover, these errors can be traced back to some other errors in the program. If we can find out whether these conditions will be met or not before actually running the program, we can benefit both by being able to generate efficient code and by being able to produce more reliable programs by careful examination of errors in the programs. Similar techniques can be used to detect semantically equivalent subexpressions or redundant statements to do more elaborate code movement optimization.The system we have constructed runs fast enough to be used as a preprocessor of a compiler. The system first creates logical assertions immediately before array elements such that these assertions must be true whenever the control passes the assertion in order for the access to be valid. These assertions are proved using similar techniques as inductive assertion methods. If an array element lies inside a loop or after a loop a loop invariant is synthesized. A theorem prover was created which has the decision capabilities for a subset of arithmetic formulas. We can use this prover to prove some valid formulas, but we can also use it to generalize nonvalid formulas so that we can hypothesize more general loop invariants.Theoretical considerations on automatic synthesis of loop invariants have been taken into account and a complete formula for loop invariants was obtained. We reduced the problem of loop invariant synthesis to the computation of this formula. This new approach of the synthesis of loop invariant will probably give more firmer basis for the automatic generation of loop invariants in general purpose verifiers.

References

  1. Cousot, P. & R. Cousot, Static verification of dynamic type properties of variables, Research Report # 25, Laboratoire d'Informatique,U.S.M.G.,Grenoble.Google ScholarGoogle Scholar
  2. Dijkstra, E. W., Guarded commands, nondeterminacy and formal derivation of programs, Comm. ACM 18, 8, August, 1975, pp. 453-457. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. German, S. M. & B. Wegbreit, A synthesizer of inductive assertions, IEEE Trans. of Software Engineering, Vol. SE-1, No.1, March 1975, pp.68-75.Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Katz, S. M. & Z. Manna, A logical analysis of programs, Comm. ACM 19, 4, April, 1976, pp. 188-206. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. King, J. C. A program verifier, Ph.D. thesis, Dept. of Comp. Sci., Carnegie-Mellon University, September 1969. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. McCarthy, J. & P. J. Hayes, Some philosophical problems from the standpoint of artificial intelligence, Machine Intelligence 4, American-Elsevier , pp. 463-502.Google ScholarGoogle Scholar
  7. Suzuki, N., Automatic verification of programs with complex data structures, Ph.D. thesis, Dept. of Comp. Sci., Stanford University, STAN-CS-76-552, February, 1976. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Suzuki, N., Iteration induction method, In preparation.Google ScholarGoogle Scholar
  9. Suzuki, N., Frame problems in Floyd-Hoare logic, In preparation.Google ScholarGoogle Scholar
  10. Wegbreit, B., The synthesis of loop predicates, Comm. ACM 17, 2, Feb. 1974, pp. 102-112. Google ScholarGoogle ScholarDigital LibraryDigital Library

Recommendations

Comments

Login options

Check if you have access through your login credentials or your institution to get full access on this article.

Sign in
  • Published in

    cover image ACM Conferences
    POPL '77: Proceedings of the 4th ACM SIGACT-SIGPLAN symposium on Principles of programming languages
    January 1977
    280 pages
    ISBN:9781450373500
    DOI:10.1145/512950

    Copyright © 1977 ACM

    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    • Published: 1 January 1977

    Permissions

    Request permissions about this article.

    Request Permissions

    Check for updates

    Qualifiers

    • Article

    Acceptance Rates

    POPL '77 Paper Acceptance Rate25of105submissions,24%Overall Acceptance Rate824of4,130submissions,20%

    Upcoming Conference

    POPL '25

PDF Format

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader