-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Locked PDB file blocks GDExtension compilation when Editor is launched within debugging #82536
Comments
Ah I remembered that Casey Muratori solved this problem by passing the some pdb related parameter to cl (%random% to make pdb has a random name everytime) when recompiling dll. When vs loads the new DLL, it loads the new PDB file as well. |
Here is workaround based on the previous advice. pdb_safe_build.cmd: set "pdb_path=c:\dev\godot\fmandate-gd\rust\target\fmandate_%RANDOM%_%RANDOM%.pdb"
echo %pdb_path% > target\pdb_path.txt
cargo build
copy target\debug\fmandate.pdb %pdb_path% build.rs: use std::fs;
fn main() {
//
if let Ok(pdb_path) = fs::read_to_string("target/pdb_path.txt") {
println!("cargo:rustc-link-arg=/PDBALTPATH:{}", pdb_path);
}
} |
I don't use Visual Studio (just the command line tools sometimes), so I don't know much about how .pdb files work. Would it be enough to just copy the .pdb file the same as we do with the .dll file (adding If VS is finding the .pdb file simply by looking for a file named just like the .dll, such that copying it would work, I think it'd be fine for Godot to copy it if it's present. But I don't know if there's more to it than that. |
I don't think that would help, AFAIK the PDB path is part of the binary so this would only work if we somehow patched the DLL, which I don't think it is feasible. I'm not sure what the solution for this would be, if there's even anything that Godot can do about it. |
Perhaps then this is a documentation thing for folks using Visual Studio? The code snippets folks posted above seem to configure Visual Studio to use a random name for the .pdb file on each compile. Perhaps putting those in the docs somewhere would be sufficient? (Do those .pdb files with random names get cleaned up eventually, though? Or, does the directory slowly fill up with more and more .pdb files? If so, those code snippets may need some additional improvements, perhaps attempting to clean up all the .pdb files that aren't locked?) |
they slowly fill up. though, in is generated in the working directory and the use case is pretty advanced, I think user will not be taken by surprise with this behavior... khm, actually, it could be easily enhanced - just try to remove all PDBs by pattern and ignore failure of the active PDB removal attempt. |
As vnen said, the path to the PDB is written inside the DLL. I solved this at the I can make these changes to the example project in |
##HHere you have a Scontructor rewritten by you that works correctly in Windows 11, but in VScode with Scons, thank you very much. And don't forget to put reloadable=true in the "gdexample.gdextension" file in the [configuration] part. Here is an example of that file.
https://gitlab.com/kone9/godot-engine-4.2-template-gdextension-with-vscode-windows-11/-/blob/main/Godot_proyect/bin/gdexample.gdextension?ref_type=heads and here is a template with preconfigured Vscode where you can verify correct operation in Windows 11.https://gitlab.com/kone9/godot-engine-4.2-template-gdextension-with-vscode-windows-11 |
I thought just occurred to me that the Windows API has some stuff to handle the PE format (which includes DLLs), so it might be possible to actually patch the copied DLL and change its PDB. This is kind of like how rcedit works, though itself doesn't provide anything about PDB. I'm not sure if it is a regular resource string, but if it is then it's possible to edit. Naturally, this would be Windows only since it relies on the Windows API, but this problem happens only on Windows anyway. I'll try to test this later. |
The path to the PDB is stored somewhere at the end of the file with the label It looks like you can safely replace the name of the PDB by editing the DLL file. The debugger finds the PDB by its new name and blocks it! So the breakpoints are working and the values of the variables are visible. But most likely you cannot change the length of the original string, usually this should not be a problem. And I do not know what is between the Also, information about |
I tested and it's not included in the resources, so my original idea can't really work. However, as @DmitriySalnikov points out, this information is in the headers of the DLL. We can do a similar thing to figure out where the specific header is and patch it. I've found this project which removes the PDB path and I believe something similar can be done to replace it instead. This is a complex approach, but I think it's safer than trying to patch the binary directly at some arbitrary address. |
I made my project to test the idea of replacing the This project copies the Limitations:
Testing: Untitled.mp4Is it worth trying to port this to Godot? |
The code in your test project doesn't seem overly large or complex. Personally, I think it'd be worth try to port to Godot. This feature is only useful to MSVC users, but it seems like the impact would be minimal, both as far as code maintenance (since it looks pretty simple) and performance (since this only needs to be attempted once per reloadable GDExtension on editor startup), so I'd be for it. |
Godot version
v4.2.dev (4c3dc26)
System information
Godot v4.2.dev (4c3dc26) - Windows 10.0.19042 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1660 Ti (NVIDIA; 31.0.15.3713) - Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (12 Threads)
Issue description
When Godot Editor is launched within debugging session, it locks PDB file, preventing GDextension compilation
Very similar issue with DLL blocking was fixed recently in this PR: #80188. That works fine when Editor launched without debugger, but with debugger it also blocks PDB. Could we copy it the same way?
Steps to reproduce
scons dev_build=yes debug_symbols=yes platform=windows compiledb=yes -j8
git clone https://github.com/godot-rust/gdext.git && cd gdext/examples/dodge-the-creeps/rust
cargo build --package dodge-the-creeps --lib
path_to_godot_working_copy\bin\godot.windows.editor.x86_64.exe --editor --path ../godot
(that's path fromrust
dir togdext/examples/dodge-the-creeps/godot
)./src/player.rs
(gdext/examples/dodge-the-creeps/rust/src/player.rs
) in any texty editor and append following line to the end:impl Player { fn hello() {} }
note: LINK : fatal error LNK1201: error writing to program database 'C:\dev\reload_lab\gdext\target\debug\deps\dodge_the_creeps.pdb'; check for insufficient disk space, invalid path, or insufficient privilege
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: