profelis / daScript-plugin

daScript language support
https://marketplace.visualstudio.com/items?itemName=profelis.dascript-plugin
MIT License
9 stars 3 forks source link

Internal error after version 1.1.4 #23

Closed MaxwellGengYF closed 3 days ago

MaxwellGengYF commented 1 month ago

After updated to vscode plugin version 1.1.4, all files' compile have this error:

[Server(26804) cpp_project] Started and initialize received
[Server(26804) cpp_project] Document changed: file:///d%3A/cpp_project/modules/daScript/scripts/renderer/post_pass/pp_init.das
> validating $$$completion$$$.das version 1
> cwd c:\Users\vip\.vscode\extensions\profelis.dascript-plugin-1.1.6\server
> exec D:\cpp_project\bin\release\daScript.exe validate_file.das -- --port ${port} --file C:\Users\vip\AppData\Local\Temp\250b83cc_0_1_$$$completion$$$.das --original-file \$$$completion$$$.das --result C:\Users\vip\AppData\Local\Temp\250b83cc_0_1_$$$completion$$$.das_res --ignore-shared-modules --global-completion
internal error: Validation process exited with code 3221225477 but no errors were reported. Please report this issue.
profelis commented 1 month ago

Hi! Run please command line from log in given ‘cwd’ folder (better with attached debugger). And send me full log and call stack (from debugger).

https://learn.microsoft.com/en-us/answers/questions/1036492/dll-crash-on-exit-with-error-3221225477

Error 3221225477 is hex 0xC000005 which is an access violation. You should step through the code in the debugger to identify cause of the problem. That's about all I can suggest without any further relevant information.

MaxwellGengYF commented 1 month ago

The most interesting thing is, I can't even reproduce this bug from command line, by simply copy command-line after 'exec' and run it under 'cwd' folder, the process simply return 0 instead.

profelis commented 1 month ago

After this lines I print raw output

console.log('internal error: Validation process exited with code', exitCode, 'but no errors were reported. Please report this issue.')
console.log('"""', output, '"""')

maybe there is something interesting where? Try with debug build please, I need call stack or more logs.

profelis commented 1 month ago

The most interesting thing is, I can't even reproduce this bug from command line, by simply copy command-line after 'exec' and run it under 'cwd' folder, the process simply return 0 instead.

my bad, replace --file C:\Users\vip\AppData\Local\Temp\250b83cc_0_1_$$$completion$$$.das --original-file \$$$completion$$$.das with path to empty das file, because this links is broken and result are different. Just create empty das file in cwd folder and pass it as --file (without --original-file)

MaxwellGengYF commented 1 month ago

I still can not reproduce this crash in debuger (both debug-build and release build with pdb) or command-line, it only happend in plugin's output. But I found that this crash only happened if I replace 'das_aligned_alloc16' and 'das_aligned_free16' into another memory allocator like 'mimalloc'. So there is maybe any potential memory out-of-range access I guess?

MaxwellGengYF commented 1 month ago

By brute-force debugging, I finally lock down the problem at "module_builtin_rtti.cpp". In functions start with 'rtti_builtin_structure_foreach', memory allocated by

DebugInfoHelper helper;

has been deallocated after function call, but pointers generated in native-call may have still been using after these calls, thus an illegal-access is triggered.

profelis commented 1 month ago

Can you give me call stack? I have only one usage of this function

mod |> for_each_structure() <| $(s)
        res |> parse_struct(s)

, but I don't see how s argument can be used after call

profelis commented 1 month ago

rtti_builtin_structure_foreach

After few seconds ) I just realized that I don't use this function at all. This is bind for das function structure_for_each_annotation, from rtti module, but I use ast module (to get more info). I still need call stack.

btw, I can complitely ignore not-zero exit codes if everything else works.

zle000 commented 1 month ago

I also encountered the same problem ...

profelis commented 3 days ago

should be fixed