skip to main content
10.1145/3302516.3307346acmotherconferencesArticle/Chapter ViewAbstractPublication PagesccConference Proceedingsconference-collections
research-article

Low-cost deterministic C++ exceptions for embedded systems

Published: 16 February 2019 Publication History

Abstract

The C++ programming language offers a strong exception mechanism for error handling at the language level, improving code readability, safety, and maintainability. However, current C++ implementations are targeted at general-purpose systems, often sacrificing code size, memory usage, and resource determinism for the sake of performance. This makes C++ exceptions a particularly undesirable choice for embedded applications where code size and resource determinism are often paramount. Consequently, embedded coding guidelines either forbid the use of C++ exceptions, or embedded C++ tool chains omit exception handling altogether. In this paper, we develop a novel implementation of C++ exceptions that eliminates these issues, and enables their use for embedded systems. We combine existing stack unwinding techniques with a new approach to memory management and run-time type information (RTTI). In doing so we create a compliant C++ exception handling implementation, providing bounded runtime and memory usage, while reducing code size requirements by up to 82%, and incurring only a minimal runtime overhead for the common case of no exceptions.

References

[1]
David W. Binkley. 1997. C++ in Safety Critical Systems. Ann. Softw. Eng. 4, 1-4 (Jan. 1997), 223–234. http://dl.acm.org/citation.cfm?id=590565.590588
[2]
Beman Dawes, David Abrahams, and R Rivera. 2014. Boost C++ libraries. http://www.boost.org/doc/libs/1_55_0/libs/libraries.htm
[3]
Christophe de Dinechin. 2000. C++ Exception Handling for IA64. In Proceedings of the First Workshop on Industrial Experiences with Systems Software, WIESS 2000, October 22, 2000, San Diego, CA, USA, Dejan S. Milojicic (Ed.). USENIX, 67–76. http://www.usenix.org/events/wiess2000/dinechin.html
[4]
Bruce Eckel, Chuck D. Allison, and Chuck Allison. 2003. Thinking in C++, Vol. 2 (2 ed.). Pearson Education.
[5]
C++ exception handling. 2012. ARM Compiler toolchain Compiler Reference.
[6]
John B. Goodenough. 1975. Exception Handling: Issues and a Proposed Notation. Commun. ACM 18, 12 (Dec. 1975), 683–696.
[8]
Google. 2018. Google C++ Style Guide. https://google.github.io/styleguide/ cppguide.html
[9]
Halldor Isak Gylfason and Gisli Hjalmtysson. 2004. Exceptional Kernel–Using C++ exceptions in the Linux kernel.
[10]
Wolfgang A Halang and Matjaž Colnarič. 2002. Dealing with exceptions in safetyrelated embedded systems. IFAC Proceedings Volumes 35, 1 (2002), 477–482.
[11]
Pieter Hintjens. 2014. ZeroMQ: The Guide. http://zeromq.org
[12]
ISO/IEC JTC1 SC22 WG21. 2006. ISO/IEC TR 18015: Technical Report on C++ Performance. Technical Report ISO/IEC TR 18015:2006. ISO/IEC. https://www. iso.org/standard/43351.html
[13]
Jun Lang and David B. Stewart. 1998. A Study of the Applicability of Existing Exception-handling Techniques to Component-based Real-time Software Technology. ACM Trans. Program. Lang. Syst. 20, 2 (March 1998), 274–301.
[14]
Roy Levin. 1977. Program Structures for Exceptional Condition Handling. Technical Report. Carnegie-Mellon Univ. Pittsburgh PA Dept. of Computer Science.
[15]
Mark Maimone. 2014. C++ On Mars. In Proceedings of the C++ Conference (CppCon 2014).
[16]
Prakash Prabhu, Naoto Maeda, Gogul Balakrishnan, Franjo Ivančić, and Aarti Gupta. 2011. Interprocedural exception analysis for C++. In European Conference on Object-Oriented Programming. Springer, 583–608.
[17]
César A Quiroz. 1998. Using C++ efficiently in embedded applications. In Proceedings of the Embedded Systems Conference.
[18]
Richard Smith et al. 2017. Working draft, standard for programming language C++. Technical Report. Technical Report.
[19]
Alexander D Stoyenko. 2012. Constructing predictable real time systems. Vol. 146. Springer Science & Business Media.
[20]
Herb Sutter. 2018. P0709 Zero-overhead deterministic exceptions : Throwing values. Technical Report R0. SG14.

Cited By

View all
  • (2023)Panic Recovery in Rust-based Embedded SystemsProceedings of the 12th Workshop on Programming Languages and Operating Systems10.1145/3623759.3624549(66-73)Online publication date: 23-Oct-2023
  • (2022)Tighten rust’s belt: shrinking embedded Rust binariesProceedings of the 23rd ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems10.1145/3519941.3535075(121-132)Online publication date: 14-Jun-2022
  • (2020)Thriving in a crowded and changing world: C++ 2006–2020Proceedings of the ACM on Programming Languages10.1145/33863204:HOPL(1-168)Online publication date: 12-Jun-2020

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Other conferences
CC 2019: Proceedings of the 28th International Conference on Compiler Construction
February 2019
204 pages
ISBN:9781450362771
DOI:10.1145/3302516
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 the author(s) 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: 16 February 2019

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. C++
  2. error handling
  3. exceptions

Qualifiers

  • Research-article

Conference

CC '19

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)20
  • Downloads (Last 6 weeks)4
Reflects downloads up to 14 Sep 2024

Other Metrics

Citations

Cited By

View all
  • (2023)Panic Recovery in Rust-based Embedded SystemsProceedings of the 12th Workshop on Programming Languages and Operating Systems10.1145/3623759.3624549(66-73)Online publication date: 23-Oct-2023
  • (2022)Tighten rust’s belt: shrinking embedded Rust binariesProceedings of the 23rd ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems10.1145/3519941.3535075(121-132)Online publication date: 14-Jun-2022
  • (2020)Thriving in a crowded and changing world: C++ 2006–2020Proceedings of the ACM on Programming Languages10.1145/33863204:HOPL(1-168)Online publication date: 12-Jun-2020

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media