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

v-analyzer hang or closes on windows #128

Open
phcreery opened this issue Sep 20, 2024 · 1 comment · May be fixed by #130
Open

v-analyzer hang or closes on windows #128

phcreery opened this issue Sep 20, 2024 · 1 comment · May be fixed by #130
Labels
bug Something isn't working

Comments

@phcreery
Copy link

Describe the bug

vscode: Language server closed. Server will not be restarting.

v-analyzer.log:

...
2024-09-20 14:26:16 [INFO]  Request finished                    method=textDocument/inlayHint duration=43.191ms 
2024-09-20 14:28:27 [WARN]  Hover request                       position=lsp.Position{
    line: 282
    character: 47
} uri=file:///c%3A/Users/phcre/Documents/v/imageeditor/src/main.v 
...
my-project/
├─ liba/
│  ├─ a.v
│  ├─ utils.v
│  ├─ bind.c.v
├─ src/
│  ├─ main.v
│  ├─ file_imports_liba.v
├─ v.mod
├─ README.md

Expected Behavior

LSP works as intended

Current Behavior

vscode: Language server closed. Server will not be restarting.

Reproduction Steps

  • System: Windows.
  • Put a folder in the root of the project folder with a module in it.
  • In src/main.v, reference that module in the folder in the root of the project

Possible Solution

Infinite loop happening here?

for dir != '' && dir !in root_dirs {

Additional Information/Context

No response

Environment details (v doctor output)

v doctor
V full version: V 0.4.7 faea2d9.b8c649b
OS: windows, Microsoft Windows 10 Pro v19045 64-bit
Processor: 8 cpus, 64bit, little endian,

getwd: C:\Users\phcre\Documents\v\v-analyzer
vexe: C:\Users\phcre\Documents\v\v\v.exe
vexe mtime: 2024-09-07 20:21:30

vroot: OK, value: C:\Users\phcre\Documents\v\v
VMODULES: OK, value: C:\Users\phcre.vmodules
VTMP: OK, value: C:\Users\phcre\AppData\Local\Temp\v_0

Git version: git version 2.24.1.windows.2
Git vroot status: 0.4.6-470-gb8c649b6 (84 commit(s) behind V master)
.git/config present: true

CC version: cc (Rev6, Built by MSYS2 project) 13.1.0
thirdparty/tcc status: thirdparty-windows-amd64 b425ac82

Editor name

vscode

v-analyzer Version

v-analyzer version 0.0.4-beta.1.83b7286

VS Code Extension Version

vosca.vscode-v-analyzer - Last updated 2024-03-23, 10:20:24

@phcreery phcreery added the bug Something isn't working label Sep 20, 2024
@phcreery phcreery reopened this Sep 28, 2024
@phcreery
Copy link
Author

I think it is due to "the process's output buffer being full. This can cause the child process to block because it cannot write more data to its standard output or standard error streams." in src\server\features_formatting.v
-Copilot

Reproducible using

import os

fn using_wait_then_slurp(cmd string, args []string) {
	mut p := os.new_process(cmd)
	p.set_args(args)
	p.set_redirect_stdio()
	print('running process...')

	defer {
		p.close()
	}
	p.wait()

	print('stdout:')

	mut output := p.stdout_slurp()
	$if windows {
		output = output.replace('\r\r', '\r')
	}
	dump(output)
}

fn using_slurp_then_close(cmd string, args []string) {
	mut p := os.new_process(cmd)
	p.set_args(args)
	p.set_redirect_stdio()
	print('running process...')

	defer {
		p.close()
	}

	p.run()

	print('stdout:')

	mut output := p.stdout_slurp()

	// p.wait()
	p.close()

	$if windows {
		output = output.replace('\r\r', '\r')
	}
	dump(output)
}

fn using_exec(cmd string, args []string) {
	mut res := os.execute(cmd + ' ' + args.join(' '))
	dump(res.output)
}

fn main() {
	cmd := @VEXE

	// file := 'C:\\Users\\phcre\\Documents\\v\\imageeditor\\src\\main.v'
	file := os.norm_path(@VEXEROOT + '/vlib/os/process_windows.c.v') // doesn't work
	// file := os.norm_path(@VEXEROOT + '/vlib/os/const_nix.c.v') // works
	args := ['fmt', file]
	dump(cmd)
	dump(args)

	using_wait_then_slurp(cmd, args)
	using_slurp_then_close(cmd, args)
	using_exec(cmd, args)
}

@phcreery phcreery linked a pull request Sep 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant