Jump to page: 1 2
Thread overview
[Issue 7602] New: [CTFE] Segmentation fault when using array.keys
Feb 27, 2012
Robert Clipsham
[Issue 7602] [CTFE] Segmentation fault when using array.keys on a null AA
Feb 29, 2012
Don
Mar 19, 2012
Don
Dec 03, 2012
Don
Dec 04, 2012
Don
Dec 05, 2012
Kenji Hara
February 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7602

           Summary: [CTFE] Segmentation fault when using array.keys
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: robert@octarineparrot.com


--- Comment #0 from Robert Clipsham <robert@octarineparrot.com> 2012-02-27 20:20:08 GMT ---
The following code:
----
string[] test()
{
    int[string] array;
    return array.keys;
}

enum str = test();
----
Gives a segmentation fault with dmd 2.058 and dmd master.

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


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
            Summary|[CTFE] Segmentation fault   |[CTFE] Segmentation fault
                   |when using array.keys       |when using array.keys on a
                   |                            |null AA


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2012-02-29 00:44:42 PST ---
It's because in interpretAA_keys, the type is missing from NullExp.
That's simple. But the problem is, that function is returning the wrong type
(the spec says it should return a dynamic array, it returns a static one).
If I change it to the correct type, then my inlining hack fails.
The solution is to add yet another hack to CTFE, to work around the hopelessly
broken D2 AAs.
Yet another reason to roll the implementation back.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7602


hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx


--- Comment #2 from hsteoh@quickfur.ath.cx 2012-03-18 22:30:42 PDT ---
OK, this is a very serious bug. Something is BADLY broken with CTFE:

struct AssociativeArray
{
    int *impl;
    int f()
    {
        if (impl !is null)
            auto x = *impl; // this is line 7
        return 1;
    }
}
void main() {
    int test()
    {
        AssociativeArray aa;
        return aa.f;
    }
    enum str = test();
}


This is not a fully minimized test case, but I've tried my best to reduce it as much as possible. With the latest dmd from git, this gives:

test.d(7): Error: dereference of invalid pointer 'AssociativeArray(null)'
test.d(15):        called from here: aa.f()
test.d(17):        called from here: test()


This is a VERY serious bug because apparently the condition (impl !is null) actually passes, even though impl is null!

This appears to be related to the current AssociativeArray magic (renaming the struct in the above code makes the bug go away). I'm going to bump the severity of this bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7602


hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7602



--- Comment #3 from Don <clugdbug@yahoo.com.au> 2012-03-19 05:25:40 PDT ---
(In reply to comment #2)
> OK, this is a very serious bug. Something is BADLY broken with CTFE:
> 
> struct AssociativeArray
[snip]

That test case is unrelated to the original bug. Please open a new bug report, changing the severity of both bugs if required.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7602


hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal


--- Comment #4 from hsteoh@quickfur.ath.cx 2012-03-19 07:57:25 PDT ---
OK, opened new issue bug 7732. Downgrading this bug back to original severity.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 03, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7602


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ellery-newcomer@utulsa.edu


--- Comment #5 from Don <clugdbug@yahoo.com.au> 2012-12-03 03:58:01 PST ---
*** Issue 8568 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 04, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7602


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #6 from Don <clugdbug@yahoo.com.au> 2012-12-04 07:24:21 PST ---
https://github.com/D-Programming-Language/dmd/pull/1339

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



--- Comment #7 from github-bugzilla@puremagic.com 2012-12-04 18:21:18 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/72dc992d114765cdb5aa9a2ea2357e6990bb6be2 Fix issue 7602 [CTFE] Segmentation fault when using array.keys on a null AA

The return type was set incorrectly (or not at all!).

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


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

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2