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

Trying to use proc-macro (vulkano_shaders::shader!) overflows 'main' thread's stack #11669

Closed
BoredSathvik opened this issue Mar 10, 2022 · 19 comments · Fixed by #12058
Closed

Comments

@BoredSathvik
Copy link

BoredSathvik commented Mar 10, 2022

Steps to reproduce:

  1. add these crates to Cargo.toml
vulkano = "0.28.0"
vulkano-shaders = "0.28.0"
  1. add this to main()
    mod cs {
        vulkano_shaders::shader! {
                ty: "compute",
                src: "
    #version 450
    
    layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
    
    layout(set = 0, binding = 0) buffer Data {
        uint data[];
    } buf;
    
    void main() {
        uint idx = gl_GlobalInvocationID.x;
        buf.data[idx] *= 12;
    }"
        }
    }

it should now give output thread 'main' has overflowed its stack


rust-analyzer version: 5fae65d 2022-03-07 stable,

rustc version: rustc 1.59.0 (9d1b2106e 2022-02-23)

@lnicola
Copy link
Member

lnicola commented Mar 10, 2022

Can't reproduce, can you test using a pre-release version from here?

image

Or does rust-analyzer analysis-stats . crash with the same error? See https://rust-analyzer.github.io/manual.html#vs-code for the path to the executable.

@BoredSathvik
Copy link
Author

I tried it in pre release v0.3.969 and it is still the same, it gives error as server exited and
output for rust analyzer language server as

thread 'main' has overflowed its stack
[ERROR rust_analyzer::reload] proc macro server crashed: failed to write request: The pipe is being closed. (os error 232)
[ERROR rust_analyzer::reload] proc macro server crashed: failed to write request: The pipe is being closed. (os error 232)

tried running rust-analyzer analysis-stats . gave me the same result

Database loaded:     127.31s (metadata 6.19s; build 120.25s)
  crates: 1, mods: 1, decls: 1, fns: 1
Item Collection:     16.00s
0/1 0% processing: main
thread 'main' has overflowed its stack
  exprs: 1, ??ty: 0 (0%), ?ty: 0 (0%), !ty: 0
Inference:           6.64s
Total:               22.64s

@lnicola
Copy link
Member

lnicola commented Mar 10, 2022

Strange, can anyone else reproduce this?

image

@lnicola
Copy link
Member

lnicola commented Mar 10, 2022

@BoredSathvik are you on Windows? Maybe we simply use too much stack.

@bjorn3
Copy link
Member

bjorn3 commented Mar 10, 2022

Could you run rust-analyzer analysis-stats . in a debugger and get a backtrace for the location the stack overflow happens?

@BoredSathvik
Copy link
Author

@BoredSathvik are you on Windows? Maybe we simply use too much stack.

yes

@BoredSathvik
Copy link
Author

Could you run rust-analyzer analysis-stats . in a debugger and get a backtrace for the location the stack overflow happens?

can i use windbg?

@bjorn3
Copy link
Member

bjorn3 commented Mar 10, 2022

can i use windbg?

Yes. I am not a windows user though, so I don't know what command to use to get a backtrace.

@BoredSathvik
Copy link
Author

# Call Site
00 ntdll!NtTerminateProcess
01 ntdll!RtlExitUserProcess
02 KERNEL32!ExitProcessImplementation
03 ucrtbase!exit_or_terminate_process
04 ucrtbase!common_exit
05 rust_analyzer!__scrt_common_main_seh
06 KERNEL32!BaseThreadInitThunk
07 ntdll!RtlUserThreadStart

will this work?

@bjorn3
Copy link
Member

bjorn3 commented Mar 10, 2022

It looks like that is after the stack has unwound. I have no clue how to get a backtrace before unwinding the stack though.

@BoredSathvik
Copy link
Author

BoredSathvik commented Mar 10, 2022

It looks like that is after the stack has unwound. I have no clue how to get a backtrace before unwinding the stack though.

oh, do i just copy stuff right after it panics?

@BoredSathvik
Copy link
Author

00 rust_analyzer!ZN8indexmap3map4core25IndexMapCore$LT$K$C$V$GT$11insert_full17h0d17b14a568160b7E
01 rust_analyzer!ZN5salsa7runtime11local_state10LocalState17report_query_read17h1cad625ca301c948E
02 rust_analyzer!ZN106_$LT$salsa..derived..DerivedStorage$LT$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$Q$GT$$GT$9try_fetch17ha667aa8a704db4f6E
03 rust_analyzer!ZN5salsa19QueryTable$LT$Q$GT$3get17h9a96c18e8fed29afE
04 rust_analyzer!ZN47_$LT$DB$u20$as$u20$hir_def..db..DefDatabase$GT$14file_item_tree17h165c1c466e125a84E
05 rust_analyzer!ZN97_$LT$salsa..input..InputStorage$LT$Q$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$Q$GT$$GT$9try_fetch17hf34238ea3820613eE
06 rust_analyzer!ZN7hir_def4attr14AttrsWithOwner11attrs_query17h49e141fa54082ffaE
07 rust_analyzer!ZN5salsa7runtime7Runtime28execute_query_implementation17h432f468cca285bf5E
08 rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17hf1a8ab1e21010024E
09 rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17h98310b5014030d87E
0a rust_analyzer!ZN106_$LT$salsa..derived..DerivedStorage$LT$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$Q$GT$$GT$9try_fetch17hc6d71bc66d83c888E
0b rust_analyzer!ZN5salsa19QueryTable$LT$Q$GT$3get17h96599808f4d956daE
0c rust_analyzer!ZN47_$LT$DB$u20$as$u20$hir_def..db..DefDatabase$GT$5attrs17hcdade9de6d51bfcfE
0d rust_analyzer!ZN7hir_def9lang_item9LangItems17collect_lang_item17h4cd8179efc75ad34E
0e rust_analyzer!ZN7hir_def9lang_item9LangItems22crate_lang_items_query17hae10b293d3c5711bE
0f rust_analyzer!ZN5salsa7runtime7Runtime28execute_query_implementation17h97257a7f4317c067E
10 rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17hf1a8ab1e21010024E
11 rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17he59487140b5a507aE
12 rust_analyzer!ZN106_$LT$salsa..derived..DerivedStorage$LT$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$Q$GT$$GT$9try_fetch17h00f126746a50f6fdE
13 rust_analyzer!ZN5salsa19QueryTable$LT$Q$GT$3get17h51c0b9fec21e2374E
14 rust_analyzer!ZN47_$LT$DB$u20$as$u20$hir_def..db..DefDatabase$GT$16crate_lang_items17h59ae32f9bf8e6de9E
15 rust_analyzer!ZN7hir_def9lang_item9LangItems15lang_item_query17h0fbe68c0162178dfE
16 rust_analyzer!ZN5salsa7runtime7Runtime28execute_query_implementation17h277a9654a536e815E
17 rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17hf1a8ab1e21010024E
18 rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17he45dc30d027c68c3E
19 rust_analyzer!ZN106_$LT$salsa..derived..DerivedStorage$LT$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$Q$GT$$GT$9try_fetch17h38c7fd532d5e12d0E
1a rust_analyzer!ZN5salsa19QueryTable$LT$Q$GT$3get17ha2359d55823a8b9fE
1b rust_analyzer!ZN47_$LT$DB$u20$as$u20$hir_def..db..DefDatabase$GT$9lang_item17h487e02c2ac66b53cE
1c rust_analyzer!ZN7hir_def9lang_item9LangItems15lang_item_query17h0fbe68c0162178dfE
1d rust_analyzer!ZN5salsa7runtime7Runtime28execute_query_implementation17h277a9654a536e815E
1e rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17hf1a8ab1e21010024E
1f rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17he45dc30d027c68c3E
20 rust_analyzer!ZN106_$LT$salsa..derived..DerivedStorage$LT$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$Q$GT$$GT$9try_fetch17h38c7fd532d5e12d0E
21 rust_analyzer!ZN5salsa19QueryTable$LT$Q$GT$3get17ha2359d55823a8b9fE
22 rust_analyzer!ZN47_$LT$DB$u20$as$u20$hir_def..db..DefDatabase$GT$9lang_item17h487e02c2ac66b53cE
23 rust_analyzer!ZN7hir_def9lang_item9LangItems15lang_item_query17h0fbe68c0162178dfE
24 rust_analyzer!ZN5salsa7runtime7Runtime28execute_query_implementation17h277a9654a536e815E
25 rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17hf1a8ab1e21010024E
26 rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17he45dc30d027c68c3E
27 rust_analyzer!ZN106_$LT$salsa..derived..DerivedStorage$LT$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$Q$GT$$GT$9try_fetch17h38c7fd532d5e12d0E
28 rust_analyzer!ZN5salsa19QueryTable$LT$Q$GT$3get17ha2359d55823a8b9fE
29 rust_analyzer!ZN47_$LT$DB$u20$as$u20$hir_def..db..DefDatabase$GT$9lang_item17h487e02c2ac66b53cE
2a rust_analyzer!ZN7hir_def9lang_item9LangItems15lang_item_query17h0fbe68c0162178dfE
2b rust_analyzer!ZN5salsa7runtime7Runtime28execute_query_implementation17h277a9654a536e815E
2c rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17hf1a8ab1e21010024E
2d rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17he45dc30d027c68c3E
2e rust_analyzer!ZN106_$LT$salsa..derived..DerivedStorage$LT$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$Q$GT$$GT$9try_fetch17h38c7fd532d5e12d0E
2f rust_analyzer!ZN5salsa19QueryTable$LT$Q$GT$3get17ha2359d55823a8b9fE
30 rust_analyzer!ZN47_$LT$DB$u20$as$u20$hir_def..db..DefDatabase$GT$9lang_item17h487e02c2ac66b53cE
31 rust_analyzer!ZN7hir_def9lang_item9LangItems15lang_item_query17h0fbe68c0162178dfE
32 rust_analyzer!ZN5salsa7runtime7Runtime28execute_query_implementation17h277a9654a536e815E
33 rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17hf1a8ab1e21010024E
34 rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17he45dc30d027c68c3E
35 rust_analyzer!ZN106_$LT$salsa..derived..DerivedStorage$LT$Q$C$MP$GT$$u20$as$u20$salsa..plumbing..QueryStorageOps$LT$Q$GT$$GT$9try_fetch17h38c7fd532d5e12d0E
36 rust_analyzer!ZN5salsa19QueryTable$LT$Q$GT$3get17ha2359d55823a8b9fE
37 rust_analyzer!ZN47_$LT$DB$u20$as$u20$hir_def..db..DefDatabase$GT$9lang_item17h487e02c2ac66b53cE
38 rust_analyzer!ZN6hir_ty5lower23trait_environment_query17hc629d633e5ca9a27E
39 rust_analyzer!ZN5salsa7runtime7Runtime28execute_query_implementation17h48423079aecf9d7aE
3a rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17hfc8cf1c7368bd2f3E
3b rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17hb86c00b51ed471b8E
3c rust_analyzer!ZN5salsa19QueryTable$LT$Q$GT$3get17h0f2b1e05f96c6e39E
3d rust_analyzer!ZN46_$LT$DB$u20$as$u20$hir_ty..db..HirDatabase$GT$17trait_environment17h0a67508e292ff629E
3e rust_analyzer!ZN6hir_ty5infer11infer_query17h3c616dec4163d1c1E
3f rust_analyzer!ZN5salsa7runtime7Runtime28execute_query_implementation17hdc462eb98ed47770E
40 rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17hfc8cf1c7368bd2f3E
41 rust_analyzer!ZN5salsa7derived4slot18Slot$LT$Q$C$MP$GT$4read17h994a3e3fae2b0386E
42 rust_analyzer!ZN5salsa19QueryTable$LT$Q$GT$3get17ha3dc277b3842af39E
43 rust_analyzer!ZN46_$LT$DB$u20$as$u20$hir_ty..db..HirDatabase$GT$11infer_query17hf8bbe3a11669f979E
44 rust_analyzer!ZN6hir_ty2db10infer_wait17h7ca7c2c413b683b3E
45 rust_analyzer!ZN13rust_analyzer3cli14analysis_stats58_$LT$impl$u20$rust_analyzer..cli..flags..AnalysisStats$GT$3run17h9e573f09d8fd35cdE
46 rust_analyzer!ZN4core3ptr70drop_in_place$LT$tracing_subscriber..filter..directive..ParseError$GT$17h6f8d237fa1afb57cE.llvm.10051581588487343680
47 rust_analyzer!ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h72958d03da7b3d0cE
48 rust_analyzer!ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17ha2e09256cc88be57E.llvm.15949137620119686375
49 rust_analyzer!core::ops::function::impls::impl$2::call_once
4a rust_analyzer!std::panicking::try::do_call
4b rust_analyzer!std::panicking::try
4c rust_analyzer!std::panic::catch_unwind
4d rust_analyzer!std::rt::lang_start_internal::closure$2
4e rust_analyzer!std::panicking::try::do_call
4f rust_analyzer!std::panicking::try
50 rust_analyzer!std::panic::catch_unwind
51 rust_analyzer!std::rt::lang_start_internal
52 rust_analyzer!main
53 rust_analyzer!invoke_main
54 rust_analyzer!__scrt_common_main_seh
55 KERNEL32!BaseThreadInitThunk
56 ntdll!RtlUserThreadStart

I can't find a way to add pdb file to make it readable😔

@bjorn3
Copy link
Member

bjorn3 commented Mar 10, 2022

56 stack frames shouldn't be anywhere near enough to cause a stack overflow. Weird.

@BoredSathvik
Copy link
Author

BoredSathvik commented Mar 11, 2022

56 stack frames shouldn't be anywhere near enough to cause a stack overflow. Weird.

maybe there were more but got poped after the overflow bc i breaked this like few seconds after the overflow

@Tamschi
Copy link

Tamschi commented Mar 23, 2022

I'm having the same problem, but with https://github.com/Tamschi/asteracea-website/tree/39a655cc469c8af505855ba696a6ced60667a611.

The GUI component macros create large nested expressions with a number of closures.
The Rust compiler handles it fine, but it seems to be a bit too much for r-a.

@Tamschi
Copy link

Tamschi commented Mar 23, 2022

I'm having the same problem, but with https://github.com/Tamschi/asteracea-website/tree/39a655cc469c8af505855ba696a6ced60667a611.

The GUI component macros create large nested expressions with a number of closures. The Rust compiler handles it fine, but it seems to be a bit too much for r-a.

Sorry, I should provide a bit more information.

In my case it's not crashing in the console, just in Code (Windows).
Rust Analyzer Client gives me Extension version: 0.3.987 in its log (and also the same server version), and this is the configuration:

Configuration
{
  cargoRunner: null,
  runnableEnv: null,
  inlayHints: {
    enable: true,
    renderColons: true,
    maxLength: 25,
    parameterHints: true,
    typeHints: true,
    chainingHints: true,
    closureReturnTypeHints: false,
    reborrowHints: false,
    lifetimeElisionHints: { enable: 'never', useParameterNames: false },
    hideNamedConstructorHints: false
  },
  server: { path: null, extraEnv: null },
  trace: { server: 'off', extension: false },
  debug: {
    engine: 'auto',
    sourceFileMap: {
      '/rustc/<id>': '${env:USERPROFILE}/.rustup/toolchains/<toolchain-id>/lib/rustlib/src/rust'
    },
    openDebugPane: false,
    engineSettings: {}
  },
  assist: {
    exprFillDefault: 'todo',
    importGranularity: 'crate',
    importEnforceGranularity: false,
    importPrefix: 'plain',
    importGroup: true,
    allowMergingIntoGlobImports: true
  },
  cache: { warmup: true },
  callInfo: { full: true },
  cargo: {
    autoreload: true,
    allFeatures: true,
    unsetTest: [ 'core' ],
    features: [],
    runBuildScripts: true,
    useRustcWrapperForBuildScripts: true,
    noDefaultFeatures: false,
    target: null,
    noSysroot: false,
    loadOutDirsFromCheck: true
  },
  checkOnSave: {
    enable: true,
    allFeatures: null,
    allTargets: true,
    command: 'clippy',
    noDefaultFeatures: null,
    target: null,
    extraArgs: [ '--locked' ],
    features: null,
    overrideCommand: null
  },
  completion: {
    addCallArgumentSnippets: true,
    addCallParenthesis: true,
    snippets: {
      'Arc::new': {
        postfix: 'arc',
        body: 'Arc::new(${receiver})',
        requires: 'std::sync::Arc',
        description: 'Put the expression into an `Arc`',
        scope: 'expr'
      },
      'Rc::new': {
        postfix: 'rc',
        body: 'Rc::new(${receiver})',
        requires: 'std::rc::Rc',
        description: 'Put the expression into an `Rc`',
        scope: 'expr'
      },
      'Box::pin': {
        postfix: 'pinbox',
        body: 'Box::pin(${receiver})',
        requires: 'std::boxed::Box',
        description: 'Put the expression into a pinned `Box`',
        scope: 'expr'
      },
      Ok: {
        postfix: 'ok',
        body: 'Ok(${receiver})',
        description: 'Wrap the expression in a `Result::Ok`',
        scope: 'expr'
      },
      Err: {
        postfix: 'err',
        body: 'Err(${receiver})',
        description: 'Wrap the expression in a `Result::Err`',
        scope: 'expr'
      },
      Some: {
        postfix: 'some',
        body: 'Some(${receiver})',
        description: 'Wrap the expression in an `Option::Some`',
        scope: 'expr'
      }
    },
    postfix: { enable: true },
    autoimport: { enable: true },
    autoself: { enable: true },
    privateEditable: { enable: false }
  },
  diagnostics: {
    enable: true,
    enableExperimental: true,
    disabled: [],
    remapPrefix: {},
    warningsAsHint: [],
    warningsAsInfo: []
  },
  experimental: { procAttrMacros: true },
  files: { watcher: 'client', excludeDirs: [] },
  highlightRelated: {
    references: true,
    exitPoints: true,
    breakPoints: true,
    yieldPoints: true
  },
  highlighting: { strings: true },
  hover: { documentation: true, linksInHover: true },
  hoverActions: {
    debug: true,
    enable: true,
    gotoTypeDef: true,
    implementations: true,
    references: false,
    run: true
  },
  joinLines: {
    joinElseIf: true,
    removeTrailingComma: true,
    unwrapTrivialBlock: true,
    joinAssignments: true
  },
  lens: {
    debug: true,
    enable: true,
    implementations: true,
    run: true,
    methodReferences: false,
    references: false,
    enumVariantReferences: false,
    forceCustomCommands: true
  },
  linkedProjects: [],
  lruCapacity: null,
  notifications: { cargoTomlNotFound: true },
  primeCaches: { numThreads: 0 },
  procMacro: { enable: true, server: null, ignored: {}, enabled: true },
  runnables: { overrideCargo: null, cargoExtraArgs: [] },
  rustcSource: null,
  rustfmt: {
    extraArgs: [],
    overrideCommand: null,
    enableRangeFormatting: false
  },
  workspace: { symbol: { search: { scope: 'workspace', kind: 'only_types' } } },
  'cargo-watch': { command: 'clippy' },
  rainbowHighlightingOn: true,
  updates: { channel: 'nightly' }
}

@jonas-schievink
Copy link
Contributor

#12058 increases the stack size on Windows to match the default on Linux (for both the LSP server and the proc-macro process). It would be great if you could test this once that is included in a release.

@bors bors closed this as completed in 1894473 Apr 22, 2022
@CGMossa
Copy link

CGMossa commented Jun 30, 2022

I'm getting this issue again. Using the latest rust, r-a, and compiling bevy.

@lnicola
Copy link
Member

lnicola commented Jul 1, 2022

@CGMossa #12600

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

Successfully merging a pull request may close this issue.

6 participants