Skip to content

Division by zero by variables and with assignments in a function or interactive leads to crash: 1.4-dev and 1.2 #562

@Twenkid

Description

@Twenkid

Constants and literals seem not to crash and also sometimes if there is a division by 0, but without assignment to a variable in the REPL (sometimes it does though).

1.2:

1: Variables command line:

[cling]$ int a = 343, b = 0;
[cling]$ int c = a/b;
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM-18.so.18.1 0x0000783f08994c96 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54
1  libLLVM-18.so.18.1 0x0000783f08992c22 llvm::sys::RunSignalHandlers() + 34
2  libLLVM-18.so.18.1 0x0000783f0899535b
3  libc.so.6          0x0000783f07442520
4  libc.so.6          0x0000783f0f3e001d
5  libc.so.6          0x0000783f0f3e0050
6  libc.so.6          0x0000783f0f3e006d
7  libLLVM-18.so.18.1 0x0000783f0a59aaa2
8  cling              0x000061efb21f4c76 cling::IncrementalExecutor::runStaticInitializersOnce(cling::Transaction&) + 278
9  cling              0x000061efb22123c0 cling::Interpreter::executeTransaction(cling::Transaction&) + 48
10 cling              0x000061efb2205d6d cling::IncrementalParser::commitTransaction(llvm::PointerIntPair<cling::Transaction*, 2u, cling::IncrementalParser::EParseResult, llvm::PointerLikeTypeTraits<cling::Transaction*>, llvm::PointerIntPairInfo<cling::Transaction*, 2u, llvm::PointerLikeTypeTraits<cling::Transaction*>>>&, bool) + 1021
11 cling              0x000061efb220ac7a cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) + 106
12 cling              0x000061efb220fdff cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) + 143
13 cling              0x000061efb221032f cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, cling::Value*, cling::Transaction**, bool) + 399
14 cling              0x000061efb2260b6a cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) + 602
15 cling              0x000061efb22780c2 cling::UserInterface::runInteractively(bool) + 610
16 cling              0x000061efb21171ab main + 2747
17 libc.so.6          0x0000783f07429d90
18 libc.so.6          0x0000783f07429e40 __libc_start_main + 128
19 cling              0x000061efb2117ee5 _start + 37
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: cling
[1]    1917616 floating point exception (core dumped)  cling

[cling]$ 1/0
input_line_3:2:3: warning: division by zero is undefined [-Wdivision-by-zero]
 1/0
  ^~

(int) 8
[cling]$ 
[cling]$ 0/0
input_line_5:2:3: warning: division by zero is undefined [-Wdivision-by-zero]
 0/0
  ^~
(int) 8
[cling]$ 0/0;
input_line_6:2:3: warning: division by zero is undefined [-Wdivision-by-zero]
 0/0;
  ^~
[cling]$ int a = 0;
[cling]$ 0/a
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM-18.so.18.1 0x00007a6de6d94c96 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54
1  libLLVM-18.so.18.1 0x00007a6de6d92c22 llvm::sys::RunSignalHandlers() + 34
2  libLLVM-18.so.18.1 0x00007a6de6d9535b
3  libc.so.6          0x00007a6de5842520
4  libc.so.6          0x00007a6de36f102c
5  cling              0x000056590b5619bc cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const + 204
6  cling              0x000056590b57c833 cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) + 195
7  cling              0x000056590b57cf87 cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) + 535
8  cling              0x000056590b57d32f cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, cling::Value*, cling::Transaction**, bool) + 399
9  cling              0x000056590b5cdb6a cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) + 602
10 cling              0x000056590b5e50c2 cling::UserInterface::runInteractively(bool) + 610
11 cling              0x000056590b4841ab main + 2747
12 libc.so.6          0x00007a6de5829d90
13 libc.so.6          0x00007a6de5829e40 __libc_start_main + 128
14 cling              0x000056590b484ee5 _start + 37
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: cling
[1]    1917806 floating point exception (core dumped)  cling

...

  • With constant(s) and literals it doesn't always crash:
[cling]$ const c = 0
input_line_3:2:8: error: a type specifier is required for all declarations
 const c = 0
 ~~~~~ ^
[cling]$ const int c = 0;
[cling]$ 23/c;
input_line_5:2:4: warning: division by zero is undefined [-Wdivision-by-zero]
 23/c;
   ^~
[cling]$ int a = 34;
[cling]$ a/c;
input_line_7:2:3: warning: division by zero is undefined [-Wdivision-by-zero]
 a/c;
  ^~
[cling]$ int b = 0;
[cling]$ c/a;
[cling]$ a/c;
input_line_10:2:3: warning: division by zero is undefined [-Wdivision-by-zero]
 a/c;
  ^~
[cling]$ int v2 = 544;

[cling]$ v2/b;
[cling]$ v2
(int) 544
[cling]$ b
(int) 0
[cling]$ int x = v2/b;
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM-18.so.18.1 0x000076c593394c96 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54
1  libLLVM-18.so.18.1 0x000076c593392c22 llvm::sys::RunSignalHandlers() + 34
2  libLLVM-18.so.18.1 0x000076c59339535b
3  libc.so.6          0x000076c591e42520
4  libc.so.6          0x000076c59204101d
5  libc.so.6          0x000076c592041050
6  libc.so.6          0x000076c59204106d
7  libLLVM-18.so.18.1 0x000076c594f9aaa2
8  cling              0x00005baefda08c76 cling::IncrementalExecutor::runStaticInitializersOnce(cling::Transaction&) + 278
9  cling              0x00005baefda263c0 cling::Interpreter::executeTransaction(cling::Transaction&) + 48
10 cling              0x00005baefda19d6d cling::IncrementalParser::commitTransaction(llvm::PointerIntPair<cling::Transaction*, 2u, cling::IncrementalParser::EParseResult, llvm::PointerLikeTypeTraits<cling::Transaction*>, llvm::PointerIntPairInfo<cling::Transaction*, 2u, llvm::PointerLikeTypeTraits<cling::Transaction*>>>&, bool) + 1021
11 cling              0x00005baefda1ec7a cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) + 106
12 cling              0x00005baefda23dff cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) + 143
13 cling              0x00005baefda2432f cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, cling::Value*, cling::Transaction**, bool) + 399
14 cling              0x00005baefda74b6a cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) + 602
15 cling              0x00005baefda8c0c2 cling::UserInterface::runInteractively(bool) + 610
16 cling              0x00005baefd92b1ab main + 2747
17 libc.so.6          0x000076c591e29d90
18 libc.so.6          0x000076c591e29e40 __libc_start_main + 128
19 cling              0x00005baefd92bee5 _start + 37
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: cling
[1]    1917963 floating point exception (core dumped)  cling

Is it because of no ";" -- the same behavior with:

[cling]$ int v2 = 544;
[cling]$ int b = 0;
[cling]$ int x = v2/b;
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM-18.so.18.1 0x00007a358b794c96 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54
1  libLLVM-18.so.18.1 0x00007a358b792c22 llvm::sys::RunSignalHandlers() + 34
2  libLLVM-18.so.18.1 0x00007a358b79535b
3  libc.so.6          0x00007a358a242520
4  libc.so.6          0x00007a358a88801d
5  libc.so.6          0x00007a358a888050
6  libc.so.6          0x00007a358a88806d
7  libLLVM-18.so.18.1 0x00007a358d39aaa2
8  cling              0x000061fcf5137c76 cling::IncrementalExecutor::runStaticInitializersOnce(cling::Transaction&) + 278
9  cling              0x000061fcf51553c0 cling::Interpreter::executeTransaction(cling::Transaction&) + 48
10 cling              0x000061fcf5148d6d cling::IncrementalParser::commitTransaction(llvm::PointerIntPair<cling::Transaction*, 2u, cling::IncrementalParser::EParseResult, llvm::PointerLikeTypeTraits<cling::Transaction*>, llvm::PointerIntPairInfo<cling::Transaction*, 2u, llvm::PointerLikeTypeTraits<cling::Transaction*>>>&, bool) + 1021
11 cling              0x000061fcf514dc7a cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) + 106
12 cling              0x000061fcf5152dff cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) + 143
13 cling              0x000061fcf515332f cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, cling::Value*, cling::Transaction**, bool) + 399
14 cling              0x000061fcf51a3b6a cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) + 602
15 cling              0x000061fcf51bb0c2 cling::UserInterface::runInteractively(bool) + 610
16 cling              0x000061fcf505a1ab main + 2747
17 libc.so.6          0x00007a358a229d90
18 libc.so.6          0x00007a358a229e40 __libc_start_main + 128
19 cling              0x000061fcf505aee5 _start + 37
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: cling
[1]    1918429 floating point exception (core dumped)  cling

No assignment (the same)

[cling]$ int v2=544;
[cling]$ int b= 0;
[cling]$ v2/b
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): (...)

**1.4-dev**
****************** CLING ******************
* Type C++ code and press enter to run it *
*     Type .? for help and .q to exit     *
*******************************************
[cling]$ int f(){ int a = 0; int b = 34; return b/a;}
[cling]$ f();
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  cling     0x00005a1b1abf6e92 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 66
1  cling     0x00005a1b1abf4356
2  libc.so.6 0x000077e69a245330
3  libc.so.6 0x000077e69aaa301a
4  libc.so.6 0x000077e69aaa5034
5  cling     0x00005a1b1aad17e8 cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const + 200
6  cling     0x00005a1b1aaeab58 cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) + 200
7  cling     0x00005a1b1aaeb318 cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) + 520
8  cling     0x00005a1b1aaeb632 cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, cling::Value*, cling::Transaction**, bool) + 338
9  cling     0x00005a1b1ab3d407 cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) + 599
10 cling     0x00005a1b1ac1abbf cling::UserInterface::runInteractively(bool) + 623
11 cling     0x00005a1b1a8f2e91 main + 3073
12 libc.so.6 0x000077e69a22a1ca
13 libc.so.6 0x000077e69a22a28b __libc_start_main + 139
14 cling     0x00005a1b1a9e12e5 _start + 37
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./bin/cling
Floating point exception (core dumped)
  • The assignment when division by 0 with variables lead to crash, while before the assignment there was no response:
[cling]$ const int z = 0; 
[cling]$ 434/z
input_line_4:2:5: warning: division by zero is undefined [-Wdivision-by-zero]
 434/z
    ^~
(int) 8                                                                                                                                                
[cling]$ 55454/z
input_line_6:2:7: warning: division by zero is undefined [-Wdivision-by-zero]
 55454/z
      ^~
(int) 8                                                                                                                                                
[cling]$ const d = 35;
input_line_7:2:8: error: a type specifier is required for all declarations
 const d = 35;
 ~~~~~ ^
[cling]$ const int d = 345;                                                                                                                            
[cling]$ d/z
input_line_9:2:3: warning: division by zero is undefined [-Wdivision-by-zero]
 d/z
  ^~
(int) 8                                                                                                                                                
[cling]$ d/z;
input_line_10:2:3: warning: division by zero is undefined [-Wdivision-by-zero]
 d/z;
  ^~
[cling]$ int v = 3434;                                                                                                                                 
[cling]$ v/z;
input_line_12:2:3: warning: division by zero is undefined [-Wdivision-by-zero]
 v/z;
  ^~
[cling]$ int zvar = 0;                                                                                                                                 
[cling]$ v/zv
input_line_14:2:4: error: use of undeclared identifier 'zv'
 v/zv
   ^
[cling]$ v/zvar;                                                                                                                                       
[cling]$ auto x = v/zvar
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  cling     0x00006069442b5e92 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 66
1  cling     0x00006069442b3356
2  libc.so.6 0x00007542d6645330
3  libc.so.6 0x00007542d644e041
4  libc.so.6 0x00007542d644e10c
5  libc.so.6 0x00007542d644e139
6  cling     0x0000606946e5ff3b
7  cling     0x0000606944190a93 cling::IncrementalExecutor::runStaticInitializersOnce(cling::Transaction&) + 275
8  cling     0x00006069441abef0 cling::Interpreter::executeTransaction(cling::Transaction&) + 48
9  cling     0x000060694419fcaa cling::IncrementalParser::commitTransaction(llvm::PointerIntPair<cling::Transaction*, 2u, cling::IncrementalParser::EParseResult, llvm::PointerLikeTypeTraits<cling::Transaction*>, llvm::PointerIntPairInfo<cling::Transaction*, 2u, llvm::PointerLikeTypeTraits<cling::Transaction*>>>&, bool) + 794
10 cling     0x00006069441a5229 cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) + 105
11 cling     0x00006069441aa1a1 cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) + 145
12 cling     0x00006069441aa632 cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, cling::Value*, cling::Transaction**, bool) + 338
13 cling     0x00006069441fc407 cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) + 599
14 cling     0x00006069442d9bbf cling::UserInterface::runInteractively(bool) + 623
15 cling     0x0000606943fb1e91 main + 3073
16 libc.so.6 0x00007542d662a1ca
17 libc.so.6 0x00007542d662a28b __libc_start_main + 139
18 cling     0x00006069440a02e5 _start + 37
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./bin/cling
        Floating point exception (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions