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

Extension inserts null bytes at end of meson.build file after saving #253

Closed
clstatham opened this issue Jul 14, 2024 · 10 comments
Closed

Comments

@clstatham
Copy link

clstatham commented Jul 14, 2024

Type: Bug

I have the following simple meson.build file for a test C project. With the meson VS Code extension enabled, anytime I modify this file and save it, a handful (around 9) of null bytes are inserted at the end, causing the language server to crash and meson itself to fail to lex the file. I'm pretty new to meson so if my build file is malformed in anyway (besides the null bytes I didn't ask for), that's on me :)

Edit: If it's worth mentioning, I do have format-on-save enabled globally in VS Code, and I used the extension bisect feature to narrow it down to the Meson extension.

Edit 2: I just confirmed that it's happening when I format the document manually from the command pallet as well. So probably something to do with the language server's formatting functionality?

project('crac', 'c', default_options: 'default_library=static')
incdir = include_directories('include')
deps = []
executable(
  'crac',
  'main.c',
  include_directories: incdir,
  dependencies: deps,
)

Extension version: 1.25.1
VS Code version: Code 1.91.1 (f1e16e1e6214d7c44d078b1f0607b2388f29d729, 2024-07-09T22:06:49.809Z)
OS version: Windows_NT x64 10.0.22631
Modes:

System Info
Item Value
CPUs AMD Ryzen 9 5900X 12-Core Processor (24 x 3700)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.92GB (21.31GB free)
Process Argv --crash-reporter-id 54a44d29-4e67-454a-891a-d029558f2d94
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonnoceb:30805159
asynctok:30898717
pythonregdiag2:30936856
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
chatpanelc:31048052
dsvsc021:30996838
g316j359:31013175
pythoncenvpt:31062603
a69g1124:31058053
dvdeprecation:31068756
dwnewjupyter:31046869
impr_priority:31094925
refactorc:31093864
0c838689:31092287

@JCWasmx86
Copy link
Contributor

Sadly I wasn't able to reproduce this with any mesonlsp version I tested

@scott-wilson
Copy link

scott-wilson commented Aug 1, 2024

I'm seeing the same issue here on Windows 10 Pro. Here's the steps to reproduce:

  1. Open the project in the dir https://github.com/scott-wilson/openchecks/tree/8de1028178863dc4ba0ea7c24ecb259efcbf28ca/bindings/cpp
  2. Open the root meson.build and format (I'm doing format on save)

This should cause the error to happen.

@JCWasmx86
Copy link
Contributor

You are both on Windows, maybe it's a windows issue. I will check it later

@tristan957
Copy link
Contributor

Thanks @JCWasmx86 for investigating. I only work on Linux, so can't test.

@mdrobot7
Copy link

mdrobot7 commented Aug 3, 2024

Saw the same issue, and have been for a month or so. Had to disable the meson extension because of it. Save without formatting also works, but that's a bit of a hassle. It happens every time I save any meson.build file, I end up with NUL chars inserted in my text.

  • Windows 11 Home
  • VSCode v. 1.90.1
  • Meson extension v. 1.25.1

@JCWasmx86
Copy link
Contributor

Even on Windows I was unable to reproduce this bug:

JCWasmx86 added a commit to JCWasmx86/mesonlsp that referenced this issue Aug 3, 2024
@JCWasmx86
Copy link
Contributor

This build could fix that: https://github.com/JCWasmx86/mesonlsp/actions/runs/10226037533 Could anybody of you please try it out, whether it really fixes the problem?

@clstatham
Copy link
Author

Yes, outside of the trailing NULs at the end of the file, the formatted meson.build seems to be valid.

Also, the patched build has fixed the issue for me!

@clstatham
Copy link
Author

clstatham commented Aug 3, 2024

Also, if it helps at all, the NULs only appeared when the file is actually formatted, as in, a modification is made first (inserting or removing a newline, for instance).

@JCWasmx86
Copy link
Contributor

Also, the patched build has fixed the issue for me!

Great, then I will make a release tomorrow and make a PR here for a bump

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

5 participants