[llvm-bugs] [Bug 48747] New: Segmentation fault when a macro is defined as nothing

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 14 03:40:31 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=48747

            Bug ID: 48747
           Summary: Segmentation fault when a macro is defined as nothing
           Product: flang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedbugs at nondot.org
          Reporter: farisrehman at hotmail.co.uk
                CC: David.Truby at arm.com, jperier at nvidia.com,
                    kirankumartp at gmail.com, llvm-bugs at lists.llvm.org,
                    sscalpone at nvidia.com

A bug has been discovered regarding macros with an empty definition. The
initial reporting can be found here: https://reviews.llvm.org/D93401#2488477

The error is produced by both f18 and flang-new, suggesting it is not a driver
issue. I am not familiar with the frontend, but the error seems to occur where
the following holds true with an empty string:
https://github.com/llvm/llvm-project/blob/main/flang/lib/Parser/preprocessor.cpp#L314 

I've reproduced this error, from commit
d58512b2e31a255dccc2c9a351a4e47b2b4c9f79 as head:
frehman at server-1:~/llvm-project$ cat a.f90
program X
end
frehman at server-1:~/llvm-project$ build/bin/f18 -E -DX= a.f90
Segmentation fault
frehman at server-1:~/llvm-project$ build/bin/flang-new -E -DX= a.f90
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.
Stack dump:
0.      Program arguments: /home/frehman/llvm-project/build/bin/flang-new -fc1
-E -D X= -o - a.f90
 #0 0x0000000001d613aa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/home/frehman/llvm-projec
t/llvm/lib/Support/Unix/Signals.inc:565:11
 #1 0x0000000001d6155b PrintStackTraceSignalHandler(void*)
/home/frehman/llvm-project/llvm/lib/Suppo
rt/Unix/Signals.inc:632:1
 #2 0x0000000001d5fc53 llvm::sys::RunSignalHandlers()
/home/frehman/llvm-project/llvm/lib/Support/Si
gnals.cpp:70:5
 #3 0x0000000001d61c85 SignalHandler(int)
/home/frehman/llvm-project/llvm/lib/Support/Unix/Signals.i
nc:407:1
 #4 0x00007f8161803140 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x14140)
 #5 0x00000000040aae72
Fortran::parser::OffsetToProvenanceMappings::Map(unsigned long) const /home/f
rehman/llvm-project/flang/lib/Parser/provenance.cpp:105:47
 #6 0x00000000040bd299
Fortran::parser::TokenSequence::GetIntervalProvenanceRange(unsigned long, uns
igned long) const
/home/frehman/llvm-project/flang/lib/Parser/token-sequence.cpp:305:38
 #7 0x00000000040bd369 Fortran::parser::TokenSequence::GetProvenanceRange()
const /home/frehman/llvm
-project/flang/lib/Parser/token-sequence.cpp:313:10
 #8 0x0000000003afe447
Fortran::parser::Preprocessor::MacroReplacement(Fortran::parser::TokenSequenc
e const&, Fortran::parser::Prescanner&)
/home/frehman/llvm-project/flang/lib/Parser/preprocessor.cpp
:315:48
 #9 0x0000000003b10547 Fortran::parser::Prescanner::Statement()
/home/frehman/llvm-project/flang/lib
/Parser/prescan.cpp:165:36
#10 0x0000000003b0ff25
Fortran::parser::Prescanner::Prescan(Fortran::common::Interval<Fortran::parse
r::Provenance>) /home/frehman/llvm-project/flang/lib/Parser/prescan.cpp:74:3
#11 0x0000000003af2d11
Fortran::parser::Parsing::Prescan(std::__cxx11::basic_string<char, std::char_
traits<char>, std::allocator<char> > const&, Fortran::parser::Options)
/home/frehman/llvm-project/fl
ang/lib/Parser/parsing.cpp:81:14
#12 0x0000000001d73aa4 Fortran::frontend::FrontendAction::Execute()
/home/frehman/llvm-project/flang
/lib/Frontend/FrontendAction.cpp:56:3
#13 0x0000000001d67f23
Fortran::frontend::CompilerInstance::ExecuteAction(Fortran::frontend::Fronten
dAction&)
/home/frehman/llvm-project/flang/lib/Frontend/CompilerInstance.cpp:151:23
#14 0x0000000001d78660
Fortran::frontend::ExecuteCompilerInvocation(Fortran::frontend::CompilerInsta
nce*)
/home/frehman/llvm-project/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:83:8
#15 0x0000000001c56728 fc1_main(llvm::ArrayRef<char const*>, char const*)
/home/frehman/llvm-project
/flang/tools/flang-driver/fc1_main.cpp:57:11
#16 0x0000000001c5222c ExecuteFC1Tool(llvm::SmallVectorImpl<char const*>&)
/home/frehman/llvm-projec
t/flang/tools/flang-driver/driver.cpp:60:5
#17 0x0000000001c51bed main
/home/frehman/llvm-project/flang/tools/flang-driver/driver.cpp:89:7
#18 0x00007f81612c6d0a __libc_start_main ./csu/../csu/libc-start.c:308:16
#19 0x0000000001c5188a _start
(/home/frehman/llvm-project/build/bin/flang-new+0x1c5188a)
flang-new: error: unable to execute command: Segmentation fault
flang-new: error: flang frontend command failed due to signal (use -v to see
invocation)
flang-new version 12.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/frehman/llvm-project/build/bin
flang-new: note: diagnostic msg: Error generating preprocessed source(s) - no
preprocessable inputs.
frehman at server-1:~/llvm-project$

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210114/36848383/attachment.html>


More information about the llvm-bugs mailing list