Thread overview
[Issue 1933] New: Delimited string constants can cause segfault
Mar 20, 2008
d-bugmail
Jul 16, 2008
d-bugmail
Dec 25, 2008
d-bugmail
March 20, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1933

           Summary: Delimited string constants can cause segfault
           Product: D
           Version: 2.007
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: unknown@simplemachines.org


The documentation (which is somewhat unclear) seems to indicate that the
following is incorrect:

q"
EOS
...
EOS"

If you try this, it will cause a segfault.  The reason is that once we leave
the switch in delimitedStringConstant(), c is '\n' (because of the break.)
This ends up meaning delimleft and delimright are '\n', as best I can reason
(haven't spent time debugging code yet.)

Simple solution to me seems like either adding an if inside |if (delimleft == 0)| to check that c is not whitespace, or adding a branch before it to ignore whitespace (depending on which is the correct interpretation of the spec.)

Also would be nice if the spec were clearer (e.g. "the delimiter, whether a character or identifier, must immediately follow the " without any whitespace. If the delimiter is an identifier, it must similarly immediately proceed the terminating ".)

I realize my D version is a bit outdated, but this diff shows the problem can't have been fixed yet for 2.012:

http://www.dsource.org/projects/dsss/changeset?new=branches%2Fdmdfe-2.0%2Flexer.c%40883&old=branches%2Fdmdfe-2.0%2Flexer.c%40838

Not sure if you care for my patches, but if I have time I'll try to look into this more and attach a patch (since I'm fairly confident the whitespace isn't supposed to be allowed.)

Thanks.  I noticed this because I was writing my own lexer, not because I was actually using the heredocs... I have to say token and delimited strings complicated my lexer more than I expected...


-- 

July 16, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1933


Joseph.Gauterin@googlemail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Joseph.Gauterin@googlemail.c
                   |                            |om




------- Comment #1 from Joseph.Gauterin@googlemail.com  2008-07-16 17:06 -------
This can be reproduced using a file containing only the following:
q"
X
"

and it's still a problem in D 2.014


-- 

December 25, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1933


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla@digitalmars.com  2008-12-25 04:41 -------
Fixed dmd 2.022


--