SIGABRTがコマンドラインプログラムを終了するのはなぜですか?

SIGABRTがコマンドラインプログラムを終了するのはなぜですか?

:s私は誤ってnullバイト(^ @)(replace)コマンドを挿入するまではうまく動作するコマンドラインプログラム(パッケージマネージャを介してインストール)を使用してきました。その時点からプログラムが実行されず、代わりに次のエラーが発生します。

/usr/include/c++/9/bits/basic_string.h:1048: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_reference = const char&; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]: Assertion '__pos <= size()' failed.
Aborted (core dumped)

gnome-abrtが表示するエラーの原因は次のとおりです。

task killed by SIGABRT

具体的にSIGABRT 6

  • Linuxで実行可能ファイルが読み取るテキストファイルにnullバイトを挿入するとどうなりますか?プログラムデータファイルにヌルバイトを挿入することは、gitコミットメッセージにヌルバイトを挿入する方法と似ており、何とかgitを中断します。

  • ヌルバイトのためにそのテキストファイルを読み取ると、プログラムが中断されるか、それとも他の理由がありますか?

ベストアンサー1

マニュアルページには次のようsignal(7)に記載されています。

Signal     Value     Action   Comment
──────────────────────────────────────────────────────────────────────
SIGABRT       6       Core    Abort signal from abort(3)

そしてabort(3)

NAME
abort - cause abnormal process termination

DESCRIPTION
The  abort()  first  unblocks the SIGABRT signal, and then raises that
signal for the calling process (as though raise(3) was called).  This
results in the abnormal termination of the process

したがって、SIGABRT手続き自体が中断されると決定された場合、死亡の可能性が高い。データに対していくつかの完全性チェックを実行し、データが無効な場合は中断される可能性があります。

これassert()マクロとも呼ばれ、abort()エラーメッセージには次のビットが含まれます。

std::__cxx11::basic_string...: Assertion '__pos <= size()' failed.

これは、C ++ライブラリのどこかに無効な値が使用されていることを示しており、無効なデータが原因で発生しない可能性があることを確認しています。

おすすめ記事