[Bug sanitizer/94299] false positive: AddressSanitizer: stack-use-after-scope on address

jan.kratochvil at redhat dot com gcc-bugzilla@gcc.gnu.org
Tue Mar 24 11:44:06 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94299

--- Comment #3 from Jan Kratochvil <jan.kratochvil at redhat dot com> ---
(In reply to Andrew Pinski from comment #1)
>     #1 0x7fffdb147b04 in
> lldb_private::CommandObject::CommandObject(lldb_private::CommandInterpreter&,
> llvm::StringRef, llvm::StringRef, llvm::StringRef, unsigned int)
> (/quad/home/jkratoch/redhat/llvm-monorepo3-gccassertdebugasanO1/bin/../lib/
> liblldb.so.11git+0x3dd5b04)
> 
> Correspond to?

(gdb) frame
#14 lldb_private::CommandObject::CommandObject (this=0x6120000133c0,
interpreter=..., name=..., help=..., syntax=..., flags=<optimized out>) at
/home/jkratoch/redhat/llvm-monorepo3/lldb/source/Interpreter/CommandObject.cpp:47
47        m_cmd_help_short = std::string(help);

llvm::StringRef help is from

#15 0x00007fffdb14d6b3 in lldb_private::CommandObjectRaw::CommandObjectRaw
(flags=0, syntax=..., help=..., name=..., interpreter=..., this=0x6120000133c0)
at
/home/jkratoch/redhat/llvm-monorepo3/lldb/include/lldb/Interpreter/CommandObject.h:396

llvm::StringRef help = ""

which is from

#16 lldb_private::CommandObjectRegexCommand::CommandObjectRegexCommand
(this=0x6120000133c0, interpreter=..., name=..., help=..., syntax=...,
max_matches=10, completion_type_mask=0, is_removable=true) at
/home/jkratoch/redhat/llvm-monorepo3/lldb/source/Interpreter/CommandObjectRegexCommand.cpp:24

llvm::StringRef help

which is from

#18 CommandObjectCommandsAddRegex::DoExecute (this=<optimized out>,
command=..., result=...) at
/home/jkratoch/redhat/llvm-monorepo3/lldb/source/Commands/CommandObjectCommands.cpp:991
991         m_regex_cmd_up = std::make_unique<CommandObjectRegexCommand>(
992             m_interpreter, name, m_options.GetHelp(),
m_options.GetSyntax(), 10, 0,
993             true);

m_options.GetHelp()

which is

    llvm::StringRef GetHelp() { return (m_help.empty() ? "" : m_help); }
    llvm::StringRef GetSyntax() { return (m_syntax.empty() ? "" : m_syntax); }
    std::string m_help;
    std::string m_syntax;

Surprisingly replacing it by:

    llvm::StringRef GetHelp() { return m_help; }
    llvm::StringRef GetSyntax() { return m_syntax; }
    std::string m_help;
    std::string m_syntax;

"fixes" the problem.

Compiling with -O0 (instead of -O1) by using
-DLLVM_OPTIMIZE_SANITIZED_BUILDS=OFF also "fixes" the problem.


More information about the Gcc-bugs mailing list