www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7602] New: [CTFE] Segmentation fault when using array.keys

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



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: -------
Feb 27 2012
next sibling parent d-bugmail puremagic.com writes:
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



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


hsteoh quickfur.ath.cx changed:

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



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: -------
Mar 18 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Mar 18 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7602





 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: -------
Mar 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7602


hsteoh quickfur.ath.cx changed:

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



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: -------
Mar 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7602


Don <clugdbug yahoo.com.au> changed:

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



*** 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: -------
Dec 03 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7602


Don <clugdbug yahoo.com.au> changed:

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



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: -------
Dec 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7602




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: -------
Dec 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Dec 04 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7602




Commits pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

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

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

https://github.com/D-Programming-Language/dmd/commit/df8a7db18b1e1ad5d3ec4457fa13f2308c57c942


D1: Merge fixes for CTFE AA bugs 7602 and 7890

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