[Aldor-l] Writable string literals
Pippijn van Steenhoven
pip88nl at gmail.com
Fri Dec 14 16:30:02 EST 2007
Hi,
there is close to no use of const in the entire Aldor source. The "const"
keyword helps finding bugs that are usually hard to find: access violations
due to the attempted write to string literals. Think of the following
(imaginary) gdb session:
Program received signal SIGSEGV, Segmentation fault.
0x0123456789abcdef in function () at func.c:666
666 str[i] = 'e';
(gdb)
Now, looking at line 666 and the lines before it shows us there is nothing
wrong.. and there is indeed nothing wrong, we just wrote to a character array,
no problem. We could do something like this:
(gdb) p str
$1 = 0x1234 "Hi, I am a string literal"
and search for this string in the source. However, this method is rendered
useless when there is a compile-time derived string literal some preprocessor
directive might have instantiated. Now looking for the origin will require us
to wade through the code (if we're lucky just moving up through the stack
frames might suffice, but often it doesn't) and look for a location that might
have caused the bug.
Catching these bugs at compile time might be a good idea, but I am not sure
how well this would apply to Aldor. Maybe some developers who are more
experienced with the Aldor code could comment on this?
--
Pippijn van Steenhoven
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mail.aldor.org/pipermail/aldor-l_aldor.org/attachments/20071214/1b04e88d/attachment-0002.bin>
More information about the Aldor-l
mailing list