Thread overview
[Issue 9418] New: Segmentation fault using only datetime and stdio.
Jan 28, 2013
Knud
Feb 05, 2013
Andrej Mitrovic
Feb 05, 2013
Maxim Fomin
Feb 06, 2013
Kenji Hara
Feb 06, 2013
Walter Bright
January 28, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9418

           Summary: Segmentation fault using only datetime and stdio.
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: knud@all-technology.com


--- Comment #0 from Knud <knud@all-technology.com> 2013-01-28 13:40:45 PST ---
Here is a simple program which provoke a Segmentation fault on Linux.


#!/usr/bin/rdmd
import std.datetime;
import std.stdio;

void main()
{
auto today=~Clock.currTime().toISOString()[0..8];

writeln(today);

}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 05, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9418


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com
           Platform|x86                         |All
         OS/Version|Linux                       |All


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-05 08:54:30 PST ---
How strange, what is the tilde operating on in this code? For example:

import std.datetime;
import std.stdio;

void main()
{
    auto x1 = ~Clock; // NG
    auto x2 = ~Clock.currTime(); // NG
    auto x3 = ~Clock.currTime().toISOString(); // NG
    auto x4 = Clock.currTime().toISOString()[0 .. 8];
    auto x5 = ~x4;  // NG
    auto x5 = ~Clock.currTime().toISOString()[0 .. 8];  // works?!
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 05, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9418


Maxim Fomin <maxim@maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim@maxim-fomin.ru


--- Comment #2 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-02-05 09:51:39 PST ---
(In reply to comment #1)
> How strange, what is the tilde operating on in this code? For example:

Indeed this is strange.

> import std.datetime;
> import std.stdio;
> 
> void main()
> {
>     auto x1 = ~Clock; // NG
>     auto x2 = ~Clock.currTime(); // NG
>     auto x3 = ~Clock.currTime().toISOString(); // NG
>     auto x4 = Clock.currTime().toISOString()[0 .. 8];
>     auto x5 = ~x4;  // NG
>     auto x5 = ~Clock.currTime().toISOString()[0 .. 8];  // works?!
> }

Actually it operates on dynamic array honestly corrupting (complementing) both length and ptr properties.

import core.stdc.stdio : printf;

void main()
{
    string foo = "foo";
    printf(".length = %d, .ptr=%p\n", foo.length, foo.ptr);
    foo = ~foo[] ;
    printf(".length = %d, .ptr=%p\n", foo.length, foo.ptr);
}

My guess is that slice expression escapes internal dmd checks.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9418


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, pull,
                   |                            |wrong-code
           Severity|normal                      |major


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2013-02-05 23:22:36 PST ---
(In reply to comment #2)
> My guess is that slice expression escapes internal dmd checks.

That is correct. At least, glue layer should reject such incorrect codegen.

https://github.com/D-Programming-Language/dmd/pull/1628

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9418



--- Comment #4 from github-bugzilla@puremagic.com 2013-02-06 00:47:22 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f13ce3739b2a15c18a3e0923507a6652bda4c288 fix Issue 9418 - Segmentation fault using only datetime and stdio.

At least glue layer should reject invalid array-operation, as same as NegExp, BinExp, PowAssignExp, and PowExp.

https://github.com/D-Programming-Language/dmd/commit/cf85813054054dfe6605ef1f184bf12eab668c1e Merge pull request #1628 from 9rnsr/fix9418

Issue 9418 + 9458 - Invalid array operation should be rejected in glue layer

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9418


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------