Forum > Debugger
Damaged values of global variables with GDB 32-bit (Windows)
Igor Kokarev:
Hi,
I discovered a problem of damaged values for global variables when 32-bit app is working under GDB debugger on Windows 10.
This problem doesn't occur in 64-bit app under GDB debugger.
For example, I call ExpandEnvironmentStringsW() to get a value of global variable %LOCALAPPDATA%
For 32-bit app under GDB debugger I get damaged value:
--- Quote ---C:\Users\Р?Р?Р?С?С?\AppData\Local
--- End quote ---
Non-latin symbols are damaged.
Same 32-bit app without GDB, or 64-bit with/or without GDB returns correct value:
--- Quote ---C:\Users\Игорь\AppData\Local
--- End quote ---
You can simulate this problem - add a new global variable in Windows 10 with a path to a folder with non-Latin symbols (Russian, or French, German).
Another example where this problem occurs. My profile name in Windows 10 is "Игорь" (non-Latin symbols). And when I call Open/Save dialog window in my 32-bit app under GDB debugger I always see an error message from in Open/Save dialog that path to Desktop can't be found. See the screenshot.
Lazarus 1.8.4, fpc 3.0.4, Windows 10 64 bit, v1803.
Test app:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$APPTYPE CONSOLE}program EnvTest; function ExpandEnvironmentStringsW(lpSrc: PWideChar; lpDst: PWideChar; nSize: Cardinal): Cardinal; stdcall; external 'kernel32.dll' name 'ExpandEnvironmentStringsW'; function GetEnv(const Name: WideString): WideString;var Len : Cardinal;begin Len:=ExpandEnvironmentStringsW( PWideChar(Name), nil, 0); if Len>0 then begin SetLength(Result, Len-1); ExpandEnvironmentStringsW( PWideChar(Name), PWideChar(Result), Len ); end else Result:='';end; procedure Test(const Name : WideString);begin WriteLn( Name,' = ', GetEnv(Name) );end; begin WriteLn('Sizeof(Pointer) = ',Sizeof(Pointer)*8,' bits'); Test('%LOCALAPPDATA%'); ReadLn;end.
Thaddy:
What gdb version are you using?
Igor Kokarev:
Default GDB debugger from Lazarus 1.8.4 (fpc 3.0.4).
I think it's 7.7.1 ?
Martin_fr:
--- Quote from: Igor Kokarev on November 15, 2018, 01:38:01 pm ---For 32-bit app under GDB debugger I get damaged value:
--- Quote ---C:\Users\Р?Р?Р?С?С?\AppData\Local
--- End quote ---
Non-latin symbols are damaged.
--- End quote ---
1) For clarification, this is what you see in the watches window (there is a small chance the watches window is wrong), and you application also behave badly => i.e., your app fails, because the data is indeed wrong?
2) On the sourceforge page, in the section "windows 32" -> "Alternative debuggers" are other gdb versions, please test with those.
If (1) is "your app fails due to wrong data" => then this may go wrong when the IDE sets up the environment for the debugged app.
If (1) is "your app fails due to wrong data" => then report as a bug (if possible with results for all tested gdb versions)
ASerge:
--- Quote from: Igor Kokarev on November 15, 2018, 01:38:01 pm ---I discovered a problem of damaged values for global variables when 32-bit app is working under GDB debugger on Windows 10.
--- End quote ---
Confirm. Windows 7. Lazarus 2.0.0RC2 32x. GDB 7.7 or GDB 8.2
The program gives different result when start by F9 vs by Ctrl+Shift+F9.
GDB provides the application with corrupt environment variables (I see this in Process Explorer).
Navigation
[0] Message Index
[#] Next page