View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0020286||Lazarus||IDE||public||2011-09-18 17:32||2014-09-10 17:29|
|Priority||normal||Severity||major||Reproducibility||have not tried|
|Summary||0020286: GDB raises SIGSEGV error in String local variable changing|
|Description||When I try to modify a String local variable at runtime, Lazarus raises the SIGSEGV error. I think that the error occurs for function TGDBMIDebugger.GDBModify uses the folowing command:|
Result := ExecuteCommand('-gdb-set var %s := %s', [AExpression, S], [cfIgnoreError, cfExternal], R) and (R.State <> dsError);
Testing in the GDB.EXE, I saw that the correct command should be call [strncpy(Text, "newValue", NewSize))] instead [set var Text := "newValue"].
The NewSize value will be the greater of initial value size and new value size.
Can anybody help me to fix the error?
|Steps To Reproduce||Unzip the Project.7Z (folder: C:\TEST\Project)|
cd /d C:\TEST\Project
set var TextVar := "NewValue"
Program received signal SIGSEGV, Segmentation fault.
0x0044a0f6 in LCLPROC_$$_CONVERTUTF8TOUTF16$crc2EBDF3EE ()
Unzip the Project.7Z (folder: C:\TEST\Project)
cd /d C:\TEST\Project
call strncpy(TextVar, "NewValue", strlen("InitialValue"))
|Tags||No tags attached.|
|Fixed in Revision|
Project.7z (654,649 bytes)
strncpy is definitely not correct either. I don't think this can be easily solved in either Lazarus or GDB at this time, because there is no publicly documented (and hence guaranteed stable) function in the FPC RTL for assigning new string values to variables.
The proper way to deal with this in Lazarus at this time would probably be to give an error message when someone attempts to change the value of a string.
At current all handling of string, pchar, array of char is limited to do limits in gdb, or the stabs/dwarf debug info.
A proper implementation is currently not possible, therefore target post 1.2 (It may be changed to earlier, if development within fpc, gdb and/or lazarus make this possible)
The implementation of a safety check to prevent the attempt of setting a value to a string or similar type will be reviewed at an earlier stage.
Thanks for reporting.
Thanks for reply!
Despite the instability, I think valid to be enabled the option to modify String local variables even with warning of risks.
What about we proceed?
Yes, there will probably be an option, so it will be a warning, and the user can force the current behaviour.
There are currently other issues, that are being worked on. This issue will be proceeded, when time becomes available (sorry it may be a while before anything will be done).
Please also note, that even a warning, is by far more complex than it may sound. To detect if the variable which is about to be assigned to, is a string or similar type, may depend on the version of gdb, version of fpc, and type of debug info. This means it will be necessary to run a huge amount of tests.
|2011-09-18 17:32||rfsanet||New Issue|
|2011-09-18 17:32||rfsanet||File Added: Project.7z|
|2011-09-18 17:43||Jonas Maebe||Note Added: 0051987|
|2011-09-18 17:43||Jonas Maebe||Project||FPC => Lazarus|
|2011-09-18 18:38||Jonas Maebe||Relationship added||has duplicate 0020287|
|2011-09-18 18:48||Martin Friebe||LazTarget||=> post 1.2|
|2011-09-18 18:48||Martin Friebe||Note Added: 0051989|
|2011-09-18 18:48||Martin Friebe||Status||new => acknowledged|
|2011-09-18 18:49||Martin Friebe||Relationship added||related to 0017619|
|2011-09-18 22:14||rfsanet||Note Added: 0051999|
|2011-09-18 23:40||Martin Friebe||Note Added: 0052003|
|2013-09-03 12:07||Martin Friebe||LazTarget||post 1.2 => 1.4|
|2014-09-10 17:29||Juha Manninen||LazTarget||1.4 => -|