www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9418] New: Segmentation fault using only datetime and stdio.

reply d-bugmail puremagic.com writes:
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



Here is a simple program which provoke a Segmentation fault on Linux.



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: -------
Jan 28 2013
next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Feb 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



---

 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: -------
Feb 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
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




 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: -------
Feb 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9418




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


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: -------
Feb 06 2013
prev sibling parent d-bugmail puremagic.com writes:
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: -------
Feb 06 2013