Jump to page: 1 2
Thread overview
[Issue 15399] unaligned pointers are not @safe
Dec 03, 2015
Ketmar Dark
Dec 15, 2015
yebblies
Jun 08, 2016
Walter Bright
Sep 05, 2017
ag0aep6g@gmail.com
Mar 04, 2018
Walter Bright
Mar 04, 2018
ag0aep6g@gmail.com
Mar 12, 2018
Walter Bright
Mar 12, 2018
Walter Bright
Mar 12, 2018
Walter Bright
Mar 12, 2018
ag0aep6g@gmail.com
December 03, 2015
https://issues.dlang.org/show_bug.cgi?id=15399

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--
December 15, 2015
https://issues.dlang.org/show_bug.cgi?id=15399

yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com

--- Comment #1 from yebblies <yebblies@gmail.com> ---
One option is to ban unaligned pointer members altogether.  It could still be done by casting to size_t, so I don't think we'd be losing much.

--
June 08, 2016
https://issues.dlang.org/show_bug.cgi?id=15399

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
https://github.com/dlang/dmd/pull/5852

--
June 18, 2016
https://issues.dlang.org/show_bug.cgi?id=15399

--- Comment #3 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/a294c6e774fb2d0b40b453f2ff9896b7f99e027f fix Issue 15399 - unaligned pointers are not @safe

https://github.com/dlang/dmd/commit/077a2d729149945ca7fc704423bdb3c9fca3ab50 Merge pull request #5852 from WalterBright/fix15399

fix Issue 15399 - unaligned pointers are not @safe

--
October 01, 2016
https://issues.dlang.org/show_bug.cgi?id=15399

--- Comment #4 from github-bugzilla@puremagic.com ---
Commits pushed to stable at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/a294c6e774fb2d0b40b453f2ff9896b7f99e027f fix Issue 15399 - unaligned pointers are not @safe

https://github.com/dlang/dmd/commit/077a2d729149945ca7fc704423bdb3c9fca3ab50 Merge pull request #5852 from WalterBright/fix15399

--
September 05, 2017
https://issues.dlang.org/show_bug.cgi?id=15399

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |ag0aep6g@gmail.com
         Resolution|FIXED                       |---

--- Comment #5 from ag0aep6g@gmail.com ---
Reopening because these very slight variations are still accepted:

1) hosts[n] = Unaligned(0, new Victim);
2) Unaligned u = { p: new Victim }; hosts[n] = u;

--
March 04, 2018
https://issues.dlang.org/show_bug.cgi?id=15399

--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to ag0aep6g from comment #5)
> Reopening because these very slight variations are still accepted:
> 
> 1) hosts[n] = Unaligned(0, new Victim);
> 2) Unaligned u = { p: new Victim }; hosts[n] = u;

I don't know what that means. Can you please post a complete example?

--
March 04, 2018
https://issues.dlang.org/show_bug.cgi?id=15399

--- Comment #7 from ag0aep6g@gmail.com ---
(In reply to Walter Bright from comment #6)
> (In reply to ag0aep6g from comment #5)
> > Reopening because these very slight variations are still accepted:
> > 
> > 1) hosts[n] = Unaligned(0, new Victim);
> > 2) Unaligned u = { p: new Victim }; hosts[n] = u;
> 
> I don't know what that means. Can you please post a complete example?


//////////////////////////////// test.d //////////////////////////////// @safe:

struct Victim
{
    bool alive = true;
    ~this() { alive = false; }
}

align(1)
struct Unaligned
{
align(1):
    ubyte filler;
    Victim* p;
}

pragma(msg, Unaligned.sizeof);

void main()
{
    enum N = 100;

    Unaligned[N] hosts;

    foreach (n; 0..N)
    {
        version (original) hosts[n].p = new Victim;
        else version (variation1) hosts[n] = Unaligned(0, new Victim);
        else version (variation2)
        {
            Unaligned u = { p: new Victim };
            hosts[n] = u;
        }
        else static assert(false);
        assert(hosts[n].p.alive);
    }

    // Unaligned.p is invisible to the GC due to alignment

    void trustedCollect() @trusted { import core.memory; GC.collect(); }
    trustedCollect();

    foreach (n; 0..N)
        assert(hosts[n].p.alive); // Dangling pointer!
}
////////////////////////////////////////////////////////////////////////

These should all fail with the same error:

    dmd -version=original test.d
    dmd -version=variation1 test.d
    dmd -version=variation2 test.d

The different versions effectively do the same thing, just with different syntax.

--
March 12, 2018
https://issues.dlang.org/show_bug.cgi?id=15399

--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to ag0aep6g from comment #5)
> Reopening because these very slight variations are still accepted:

Since the original bug was fixed, I'd prefer opening new bugs for new problems, not reopening fixed bugs with variations.

--
March 12, 2018
https://issues.dlang.org/show_bug.cgi?id=15399

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=18597

--
« First   ‹ Prev
1 2