Detecting lifetime errors of std::string_view objects in C++

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Kovacs, Reka, Horvath, Gabor, Porkolab, Zoltan
Formato: Preprint
Publicado: 2024
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866916361206235136
author Kovacs, Reka
Horvath, Gabor
Porkolab, Zoltan
author_facet Kovacs, Reka
Horvath, Gabor
Porkolab, Zoltan
contents std::string view is a reference-like data structure in the C++ Standard Template Library (STL) that enables fast and cheap processing of read-only strings. Due to its wide applicability and performance enhancing power, std::string view has been very popular since its introduction in the C++17 standard. However, its careless use can lead to serious memory management bugs. As the lifetime of a std::string view is not tied to the lifetime of the referenced string in any way, it is the user's responsibility to ensure that the view is only used while the viewed string is live and its buffer is not reallocated. This paper describes a static analysis tool that finds programming errors caused by the incorrect use of std::string view. Our work included modeling std::string view operations in the analysis, defining steps to detect lifetime errors, constructing user-friendly diagnostic messages, and performing an evaluation of the checker.
format Preprint
id arxiv_https___arxiv_org_abs_2408_09325
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Detecting lifetime errors of std::string_view objects in C++
Kovacs, Reka
Horvath, Gabor
Porkolab, Zoltan
Software Engineering
std::string view is a reference-like data structure in the C++ Standard Template Library (STL) that enables fast and cheap processing of read-only strings. Due to its wide applicability and performance enhancing power, std::string view has been very popular since its introduction in the C++17 standard. However, its careless use can lead to serious memory management bugs. As the lifetime of a std::string view is not tied to the lifetime of the referenced string in any way, it is the user's responsibility to ensure that the view is only used while the viewed string is live and its buffer is not reallocated. This paper describes a static analysis tool that finds programming errors caused by the incorrect use of std::string view. Our work included modeling std::string view operations in the analysis, defining steps to detect lifetime errors, constructing user-friendly diagnostic messages, and performing an evaluation of the checker.
title Detecting lifetime errors of std::string_view objects in C++
topic Software Engineering
url https://arxiv.org/abs/2408.09325