clang++でサニタイザーを使用しています。サニタイザーでエラーが出たときに起きたとき、ずっと標準入力を受け付けている状態になり、シグナルを送っても終了できません。terminalを再起動するしか方法がないのが現状です。
原因の特定方法や、解決方法をご存知の方がいらっしゃったら教えてください。
実行コマンド
shell
1clang++ test.cpp -g -fsanitize=address && ./a.out
サニタイザーエラー内容
shell
1previously allocated by thread T0 here: 2 #0 0x10218cd9d in wrap__Znwm+0x7d (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x50d9d) 3 #1 0x10211eb54 in void* std::__1::__libcpp_operator_new<unsigned long>(unsigned long) new:235 4 #2 0x10211ea98 in std::__1::__libcpp_allocate(unsigned long, unsigned long) new:261 5 #3 0x102117233 in std::__1::allocator<int>::allocate(unsigned long) allocator.h:108 6 #4 0x10211ec6e in ft::vector<int, std::__1::allocator<int> >::__vallocate(unsigned long) vector.hpp:164 7 #5 0x10211ebfd in ft::vector<int, std::__1::allocator<int> >::vector(unsigned long) vector.hpp:29 8 #6 0x1021172ac in ft::vector<int, std::__1::allocator<int> >::vector(unsigned long) vector.hpp:28 9 #7 0x10211545e in main vector_test.cpp:43 10 #8 0x7fff204dcf3c in start+0x0 (libdyld.dylib:x86_64+0x15f3c) 11 12SUMMARY: AddressSanitizer: double-free (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x511bd) in wrap__ZdlPv+0x7d 13==66779==ABORTING
環境
shell
1❯ clang++ -v 2Homebrew clang version 13.0.0 3Target: x86_64-apple-darwin20.6.0 4Thread model: posix 5InstalledDir: /usr/local/opt/llvm/bin 6 7❯ sw_vers 8ProductName: macOS 9ProductVersion: 11.6 10BuildVersion: 20G165
試したこと
- ctrl + c, d, z等のシグナルを送る => 終了できず
- psを使って、プロセスIDを特定し
kill -p プロセスID
を実行 => 終了できず - 標準のzshからbashを起動して、同様のことを再実行。=> 同様のバグが出ます
brew uninstall llvm
でclang++をアンインストールして、デフォルトのclang++を使用しても同様のバグがでます。-fsanitize-recover=address
にフラグを変更して実行したが、同様のバグがでます。
わかったこと
デフォルトのターミナルを開いて実行したところ、正常終了しました。
vscode起因のバグだとわかりました。
現在原因を調べています。
回答1件
あなたの回答
tips
プレビュー