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

cpptools insiders (0.29.0) Segmentation fault (With simple reproduction code) - std::rotate, C++20, Linux, Clang #5727

Closed
olekolek1000 opened this issue Jul 6, 2020 · 4 comments
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service verified Bug has been reproduced Visual Studio Inherited from Visual Studio
Milestone

Comments

@olekolek1000
Copy link

Type: LanguageService

  • OS and Version: Linux x64
  • VS Code Version: 1.47.0-insiders
  • C/C++ Extension Version: 0.29.0-insiders

cpptools-srv crashes instantly after typing C++ code below (C++20 mode):

#include <vector>
#include <iostream>
#include <algorithm>
 
int main()
{
    std::vector<int> v{2, 4, 2, 0, 5, 10, 7, 3, 7, 1}; 
 
    std::cout << "before sort:      ";
    for (int n: v)
        std::cout << n << ' ';
    std::cout << '\n';
 
    // insertion sort
    for (auto i = v.begin(); i != v.end(); ++i) {
        std::rotate(std::upper_bound(v.begin(), i, *i), i, i+1);
    }
 
    std::cout << "after sort:       ";
    for (int n: v)
        std::cout << n << ' ';
    std::cout << '\n';
 
    // simple rotation to the left
    std::rotate(v.begin(), v.begin() + 1, v.end());
 
    std::cout << "simple rotate left  : ";
    for (int n: v)
        std::cout << n << ' ';
    std::cout << '\n';
 
    // simple rotation to the right
    std::rotate(v.rbegin(), v.rbegin() + 1, v.rend());
 
    std::cout << "simple rotate right : ";
    for (int n: v)
        std::cout << n << ' ';
    std::cout << '\n';
 
}

(example code from cppreference.com):
https://en.cppreference.com/w/cpp/algorithm/rotate

Steps to reproduce

  1. Copy example code from https://en.cppreference.com/w/cpp/algorithm/rotate at the bottom
  2. Run intellisense (Enable C++20 in .vscode/c_cpp_properties.json)
  3. Segmentation fault.

Logs from the command `C/C++: Log Diagnostics

-------- Diagnostics - 06/07/2020, 14:24:20
Version: 0.29.0-insiders
Current Configuration:
{
    "name": "Linux",
    "includePath": [],
    "cppStandard": "c++20",
    "compilerArgs": [],
    "cStandard": "c11",
    "intelliSenseMode": "gcc-x64",
    "browse": {
        "path": [
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /home/XXXXXX/Desktop/repro/main.cpp ]:
    /home/XXXXXX/Desktop/repro/main.cpp
Translation Unit Configurations:
[ /home/XXXXXX/Desktop/repro/main.cpp ]: not ready
    Process ID: 33716
    Memory Usage: 0 MB
    Compiler Path: /usr/bin/clang
    Includes:
        /usr/include/c++/10.1.0
        /usr/include/c++/10.1.0/x86_64-pc-linux-gnu
        /usr/include/c++/10.1.0/backward
        /usr/local/include
        /usr/lib/clang/10.0.0/include
        /include
        /usr/include
    Standard Version: c++20
    IntelliSense Mode: clang-x64
    Other Flags:
        --clang
        --clang_version=100000
Total Memory Usage: 0 MB

Logs from the language server:

sending compilation args for /home/XXXXX/Desktop/repro/main.cpp
  include: /usr/include/c++/10.1.0
  include: /usr/include/c++/10.1.0/x86_64-pc-linux-gnu
  include: /usr/include/c++/10.1.0/backward
  include: /usr/local/include
  include: /usr/lib/clang/10.0.0/include
  include: /include
  include: /usr/include
  define: __llvm__=1
  define: __clang__=1
.........a lot of defines..........
other: --clang
  other: --clang_version=100000
  stdver: c++20
  intelliSenseMode: clang-x64
Checking for syntax errors: file:///home/XXXXXX/Desktop/repro/main.cpp
Queueing IntelliSense update for files in translation unit of: /home/XXXXXX/Desktop/repro/main.cpp
cpptools/getDocumentSymbols: file:///home/XXXXXX/Desktop/repro/main.cpp (id: 4)
  Processing folder (recursive): /usr/local/include/
  Processing folder (recursive): /usr/lib/clang/10.0.0/include/
  Processing folder (recursive): /include/
  Processing folder (recursive): /usr/include/
cpptools/getFoldingRanges: file:///home/XXXXXX/Desktop/repro/main.cpp (id: 5)
cpptools/getDocumentSymbols: file:///home/XXXXXX/Desktop/repro/main.cpp (id: 6)
cpptools/abortRequest
cpptools/getDocumentSymbols
cpptools/getDocumentSymbols
cpptools/getFoldingRanges: file:///home/XXXXXX/Desktop/repro/main.cpp (id: 7)
cpptools/fileCreated: file:///home/XXXXXX/.config/Code%20-%20Insiders/logs/20200706T142658/sharedprocess.log
cpptools/fileCreated: file:///home/XXXXXX/.config/Code%20-%20Insiders/logs/20200706T142658/telemetry.log
cpptools/fileCreated: file:///home/XXXXXX/.config/Code%20-%20Insiders/logs/20200706T142658/userDataSync.log
Failed to read response from server: 22
(crash)
@sean-mcmanus sean-mcmanus added the investigate: repro This issue's repro steps needs to be investigated/confirmed label Jul 8, 2020
@sean-mcmanus sean-mcmanus added this to the 0.30.0 milestone Jul 8, 2020
@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Jul 8, 2020

A workaround appears to be to set C_Cpp.intelliSenseCacheSize to 0. Let me know if that doesn't work for you.

Simplified repro is

#include <algorithm>

int main()
{
    int v[3] = { 0, 1, 2 }; 
    std::rotate(std::begin(v), std::begin(v) + 1, std::end(v)); 
}

@olekolek1000
Copy link
Author

Works perfectly without PCH/cache :)

@sean-mcmanus
Copy link
Contributor

I mistakenly thought the bug didn't repro with VS, but Colen discovered that it did. I've filed bug https://developercommunity.visualstudio.com/content/problem/1109849/cc-intellisense-process-crashes-when-stdrotate-is.html .

@sean-mcmanus sean-mcmanus modified the milestones: 0.30.0, Tracking Jul 10, 2020
@sean-mcmanus sean-mcmanus added Visual Studio Inherited from Visual Studio and removed investigate: repro This issue's repro steps needs to be investigated/confirmed labels Jul 10, 2020
@sean-mcmanus sean-mcmanus self-assigned this Jul 20, 2020
@sean-mcmanus sean-mcmanus modified the milestones: Tracking, 0.30.0 Jul 20, 2020
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Jul 21, 2020
@sean-mcmanus sean-mcmanus removed their assignment Jul 21, 2020
@sean-mcmanus
Copy link
Contributor

@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service verified Bug has been reproduced Visual Studio Inherited from Visual Studio
Projects
None yet
Development

No branches or pull requests

2 participants