Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for loop crashes the kernel #85

Open
Vipul-Cariappa opened this issue Oct 23, 2024 · 6 comments
Open

for loop crashes the kernel #85

Vipul-Cariappa opened this issue Oct 23, 2024 · 6 comments

Comments

@Vipul-Cariappa
Copy link

Vipul-Cariappa commented Oct 23, 2024

EDITED:
Any for loop crashes the kernel. Example:

In [1]: for (int i = 0; i < 5; i++) {}

ORIGINAL ISSUE FILED:

The following code snippet crashes the kernel with 11, 14 & 17 stdc++:

In [1]: #include <iostream>
   ...: #include <string>
   ...: #include <vector>

In [2]: std::vector<std::string> strs;
   ...: strs.push_back("xeus");
   ...: strs.push_back("clang");
   ...: strs.push_back("repl");

In [3]: for (size_t i = 0; i < strs.size(); i++) {
   ...:     std::cout << strs.at(i) << std::endl;
   ...: }

But the following runs fine:

In [1]: #include <iostream>
   ...: #include <string>
   ...: #include <vector>

In [2]: std::vector<std::string> strs;
   ...: strs.push_back("xeus");
   ...: strs.push_back("clang");
   ...: strs.push_back("repl");

In [3]: std::cout << strs.at(0) << std::endl;
   ...: std::cout << strs.at(1) << std::endl;
   ...: std::cout << strs.at(2) << std::endl;
@Vipul-Cariappa Vipul-Cariappa changed the title Iteration of std::vector crashes the kernel for loop crashes the kernel Oct 23, 2024
@Vipul-Cariappa
Copy link
Author

clang-repl (LLVM 18) also crashes while executing any for loop.

❯ ./clang-repl
clang-repl> for (int i = 0; i < 5; i++) {}
clang-repl: /home/vipul/Workspace/cpp-py/compiler-research/llvm-project/clang/lib/CodeGen/CGDecl.cpp:160: void clang::CodeGen::CodeGenFunction::EmitDecl(const clang::Decl&): Assertion `VD.isLocalVarDecl() && "Should not see file-scope variables inside a function!"' failed.

@vgvassilev
Copy link
Contributor

Please open a bug against upstream llvm. I remember fixing similar problems upstream

@Vipul-Cariappa
Copy link
Author

Vipul-Cariappa commented Oct 23, 2024

LLVM 19 does not crash with the for loop example I specified above. I am trying to compile xeus-clang-repl with LLVM 19 but cannot. I get the following error:

CMake Error at CMakeLists.txt:105 (message):
  Found unsupported version: LLVM 19.1.2;

  Please set LLVM_DIR pointing to the llvm version 8.0 to 18.1.x build or
  installation folder

Please open a bug against upstream llvm.

Not required till we test with LLVM 19, I guess.


EDITED

The for loop bug is fixed with LLVM 19. I got it compiled.

@Vipul-Cariappa
Copy link
Author

Vipul-Cariappa commented Oct 23, 2024

@vgvassilev I guess we can close this issue. And put a remake saying only LLVM 19 is supported. And update the README.
But then we may not be able to use clad.

@vgvassilev
Copy link
Contributor

I am not sure I understand how this is an issue for clad?

@Vipul-Cariappa
Copy link
Author

If we use LLVM 19 and compile xeus-clang-repl, the for loop bug will be fixed. But as clad does not support LLVM 19 yet, we will remove support for clad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants