Jump to page: 1 24  
Page
Thread overview
[Issue 11447] New: Closure provide bogus values
Nov 05, 2013
deadalnix
Nov 16, 2013
Vladimir Panteleev
Nov 16, 2013
deadalnix
Dec 29, 2013
Walter Bright
Dec 29, 2013
Walter Bright
Dec 31, 2013
Walter Bright
Jan 09, 2014
deadalnix
Jan 09, 2014
Kenji Hara
Jan 10, 2014
deadalnix
Jan 10, 2014
Kenji Hara
Jan 10, 2014
deadalnix
Jan 26, 2014
deadalnix
Jan 26, 2014
Walter Bright
Jan 26, 2014
deadalnix
Jan 27, 2014
Walter Bright
Jan 27, 2014
Walter Bright
Jan 27, 2014
Vladimir Panteleev
Jan 27, 2014
Walter Bright
Jan 27, 2014
Walter Bright
Jan 27, 2014
Vladimir Panteleev
Jan 27, 2014
Walter Bright
Jan 27, 2014
Vladimir Panteleev
Jan 27, 2014
Walter Bright
Jan 27, 2014
Vladimir Panteleev
Jan 27, 2014
Vladimir Panteleev
Jan 27, 2014
Kenji Hara
Jan 27, 2014
Walter Bright
Jan 27, 2014
deadalnix
November 05, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11447

           Summary: Closure provide bogus values
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: deadalnix@gmail.com


--- Comment #0 from deadalnix <deadalnix@gmail.com> 2013-11-05 11:45:36 PST ---
Created an attachment (id=1287)
Full source code.

Executive summary, full code in the archive attached.

        auto instanciateFromResolvedArgs(Location , Template t,
TemplateArgument[] args) {

                static Template gladeulfeurah;
                gladeulfeurah = t;
                string id = args.map!(
({
                        }, delegate string(identified) {
                                assert(t is gladeulfeurah, "tagazok");
                                        assert(0);
                        })
                ).join;
        }

Here, assert(t is gladeulfeurah, "tagazok") fails, when it should succeeed.
Significant part of SDC test suite fail due to this bug (SDC crashes as a
result).

To compile what is provided in the archive :
make DMD=PATH_TO_DMD_MASTER
Run with :
LD_LIBRARY_PATH=PATH_TO_PHOBOS_MASTER ./fail

The whole source code to trigger the error is 3 source file, so it isn't that big.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 16, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11447


Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow@gmail.com
           Severity|major                       |regression


--- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> 2013-11-16 10:22:20 EET ---
OP elaborated on IRC that this is a regression from 2.063.2. The included sample is not fully reduced (DustMite run + cursory Makefile cleanup), but according to OP, separate compilation is required to reproduce the bug.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 16, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11447



--- Comment #2 from deadalnix <deadalnix@gmail.com> 2013-11-16 12:10:06 PST ---
OK, I've been able to spend some time making this report look better.

a.d :
class A {
}

import std.algorithm;
import std.array;
struct TemplateInstancier {
    auto instanciateFromResolvedArgs(A a) {
        auto bs = [B(a)];

        static A gladeulfeurah;
        gladeulfeurah = a;
        // XXX: have to put array once again to avoid multiple map.
        string id = bs.map!(
            b => b.apply!(
                function string() { assert(0); },
                delegate string(i) {
                    assert(a is gladeulfeurah, "tagazok");
                    return "";
                }
            )
        ).join;
    }
}

enum Tag {
    Undefined,
    A,
}

struct B {
    A a;
    Tag tag;

    this(A a) {
        tag = Tag.A;
        this.a = a;
    }
}

auto apply(alias undefinedHandler, alias handler)(B b) {
    final switch(b.tag) with(Tag) {
        case Undefined :
            return undefinedHandler();

        case A :
            return handler(b.a);
    }
}

fail.d:
import a;

void main() {
    auto a = new A();
    TemplateInstancier().instanciateFromResolvedArgs(a);
}

Compile via:
dmd -c -offail.o fail.d -m64 -w -debug -gc
dmd -c -ofa.o a.d -m64 -w -debug -gc
gcc -o fail fail.o a.o -m64 -lphobos2 -export-dynamic -ldl

Run via:
./fail

The program assert fail with the message tagazok. The value of the variable a in the closure is incorrect.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 29, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11447


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2013-12-28 21:21:22 PST ---
I can't get this to even link on Linux, the result is:

a.o:(.tbss+0x0): multiple definition of
`_D1a18TemplateInstancier27instanciateFromResolvedArgsMFC1a1AZv13gladeulfeurahC1a1A'
foo.o:(.tbss+0x0): first defined here
a.o: In function
`_D1a18TemplateInstancier27instanciateFromResolvedArgsMFC1a1AZv':
/home/walter/cbx/mars/a.d:7: multiple definition of
`_D1a18TemplateInstancier27instanciateFromResolvedArgsMFC1a1AZv'
foo.o:/home/walter/cbx/mars/a.d:7: first defined here
collect2: ld returned 1 exit status
--- errorlevel 1

The program compiles and runs without error on Windows.

BTW, is it possible for you to simplify the example code? I find it so convoluted as to be completely baffling.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 29, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11447



--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2013-12-28 22:42:35 PST ---
This gives the multiple definition error on Linux:

------- a.d -----------
struct A { }

void map(alias dg)(A r) { }

struct TTT {
    static auto yyy(A a) {
        map!(b => 0)(a);
    }
}
------- fail.d ---------
import a;

void main() {
    A a;
    TTT.yyy(a);
}
-----------------------

--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2013-12-29 12:11:10 PST ---
https://github.com/D-Programming-Language/dmd/pull/3045

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 31, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11447



--- Comment #6 from github-bugzilla@puremagic.com 2013-12-30 17:14:30 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/167b6b7dafd7dede3e71714de195ceff129497df fix Issue 11447 - Closure provide bogus values

https://github.com/D-Programming-Language/dmd/commit/fcf76cd0979c21cfc7d162164b081d7e181bc046 Merge pull request #3050 from 9rnsr/fix11447

fix Issue 11447 - Closure provide bogus values

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 31, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11447


Walter Bright <bugzilla@digitalmars.com> changed:

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


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 31, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11447



--- Comment #7 from github-bugzilla@puremagic.com 2013-12-31 04:13:48 PST ---
Commit pushed to 2.065 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/1ea66b6b17354a8cce69d1ef6c182e70c748e1e5 Merge pull request #3050 from 9rnsr/fix11447

fix Issue 11447 - Closure provide bogus values

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11447


deadalnix <deadalnix@gmail.com> changed:

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


--- Comment #8 from deadalnix <deadalnix@gmail.com> 2014-01-08 21:51:09 PST ---
REOPENING.

Code supplied in comment 2 still fail as follow :

a.o:(.tbss+0x0): définitions multiples de «
_D1a18TemplateInstancier27instanciateFromResolvedArgsMFC1a1AZv13gladeulfeurahC1a1A
»
fail.o:(.tbss+0x0): défini pour la première fois ici
a.o: dans la fonction «
_D1a18TemplateInstancier27instanciateFromResolvedArgsMFC1a1AZv »:
/home/deadalnix/d/tests/a.d:7: définitions multiples de «
_D1a18TemplateInstancier27instanciateFromResolvedArgsMFC1a1AZv »
fail.o:/home/deadalnix/d/tests/a.d:7: défini pour la première fois ici
collect2: error: ld returned 1 exit status

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11447



--- Comment #9 from Kenji Hara <k.hara.pg@gmail.com> 2014-01-08 22:23:01 PST ---
(In reply to comment #8)
> REOPENING.
> 
> Code supplied in comment 2 still fail as follow :
> 
> a.o:(.tbss+0x0): définitions multiples de «
> _D1a18TemplateInstancier27instanciateFromResolvedArgsMFC1a1AZv13gladeulfeurahC1a1A
> »
> fail.o:(.tbss+0x0): défini pour la première fois ici
> a.o: dans la fonction «
> _D1a18TemplateInstancier27instanciateFromResolvedArgsMFC1a1AZv »:
> /home/deadalnix/d/tests/a.d:7: définitions multiples de «
> _D1a18TemplateInstancier27instanciateFromResolvedArgsMFC1a1AZv »
> fail.o:/home/deadalnix/d/tests/a.d:7: défini pour la première fois ici
> collect2: error: ld returned 1 exit status

Do you try it with latest git head (b1aa0cb)? If not, recently fixed bug 11863 might also fix this bug.

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