[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-12-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

--- Comment #17 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/633c50a4ffd3980502eaacecf7c743e7051925a3
fix Issue 15272 - [2.069-rc2,inline] nothing written to output when -inline is
set

https://github.com/D-Programming-Language/dmd/commit/90433ba633c85ce784e971077b2af8aef389ed47
Merge pull request #5258 from MartinNowak/fix15272

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-03 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

--- Comment #16 from github-bugzi...@puremagic.com ---
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/633c50a4ffd3980502eaacecf7c743e7051925a3
fix Issue 15272 - [2.069-rc2,inline] nothing written to output when -inline is
set

https://github.com/D-Programming-Language/dmd/commit/90433ba633c85ce784e971077b2af8aef389ed47
Merge pull request #5258 from MartinNowak/fix15272

fix Issue 15272 - [2.069-rc2,inline] nothing written to output when -inline is
set

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-03 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

Walter Bright  changed:

   What|Removed |Added

   Hardware|x86_64  |All
 OS|Linux   |All

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

--- Comment #15 from Walter Bright  ---
BTW, this is a critical bug.

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

safety0ff.bugz  changed:

   What|Removed |Added

 CC||safety0ff.b...@gmail.com

--- Comment #13 from safety0ff.bugz  ---
(In reply to Martin Nowak from comment #12)
> I diggered and found https://github.com/D-Programming-Language/dmd/pull/4909
> to be the culprit.

FWIW, the following patch fixes it for me:

--- a/src/backend/cgelem.c
+++ b/src/backend/cgelem.c
@@ -3545,8 +3545,8 @@ STATIC elem * eleq(elem *e, goal_t goal)
 {
 e->E2 = e2->E1;
 eb = el_bin(OPeq,ty,eb,e2->E2);
-e2->E1 = eb;
-e2->E2 = e;
+e2->E1 = e;
+e2->E2 = eb;
 }
 else
 {

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

Martin Nowak  changed:

   What|Removed |Added

 CC||c...@dawg.eu

--- Comment #12 from Martin Nowak  ---
I diggered and found https://github.com/D-Programming-Language/dmd/pull/4909 to
be the culprit.

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

Marc Schütz  changed:

   What|Removed |Added

 CC||schue...@gmx.net

--- Comment #9 from Marc Schütz  ---
Digger blames this PR for me:
https://github.com/D-Programming-Language/dmd/pull/5060

... but this looks very unlikely to be the culprit.

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

Walter Bright  changed:

   What|Removed |Added

 CC||bugzi...@digitalmars.com

--- Comment #14 from Walter Bright  ---
(In reply to safety0ff.bugz from comment #13)
> FWIW, the following patch fixes it for me:
> 
> --- a/src/backend/cgelem.c
> +++ b/src/backend/cgelem.c
> @@ -3545,8 +3545,8 @@ STATIC elem * eleq(elem *e, goal_t goal)
>  {
>  e->E2 = e2->E1;
>  eb = el_bin(OPeq,ty,eb,e2->E2);
> -e2->E1 = eb;
> -e2->E2 = e;
> +e2->E1 = e;
> +e2->E2 = eb;
>  }
>  else
>  {

https://github.com/D-Programming-Language/dmd/pull/5253

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

--- Comment #10 from ag0ae...@gmail.com ---
(In reply to ag0aep6g from comment #7)
> Here's a reduction that segfaults reliably for me with -release -O -inline:
> 
[...]
> 

Reduced a little further, showing that bucketCount gets corrupted:

import core.stdc.stdio: printf;

pragma(inline, false) void[] calloc_(size_t bc) nothrow pure
{
debug printf("%x\n", bc); /* prints "", should print "1" */
return [];
}

void main()
{
{
File file_;
nop();
}

auto scache = StringCache(1);
}

struct File
{
~this() {}
}

void nop() {}

struct StringCache
{
this(size_t bucketCount)
{
buckets = calloc_(bucketCount)[0 .. bucketCount];
printf("");
}

void[] buckets;
}


--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

--- Comment #11 from ag0ae...@gmail.com ---
(In reply to ag0aep6g from comment #10)
> Reduced a little further, showing that bucketCount gets corrupted:
> 
[...]
> 

And further, removing -inline from the equation (still needs -release -O):

import core.stdc.stdio: printf;

void[] calloc_(size_t bc) nothrow pure
{
debug printf("%x\n", bc); /* prints "", should print "1" */
return [];
}

void main()
{
try nop();
finally {}

StringCache scache;
size_t bucketCount = 1;
void[]* buckets = 
*buckets = calloc_(bucketCount)[0 .. bucketCount];
printf("");
}

void nop() {}

struct StringCache
{
void[] buckets;
}


--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

--- Comment #2 from ag0ae...@gmail.com ---
(In reply to bb.temp from comment #0)
> So far I'm here but it doesn't capture the essence of the problem.
> 
> ---
[...]
> ---

As far as I can tell, everything works as expected in that code.

The different `children` arrays are GC allocated (via ~=), but the `Foo`s
themselves are not. So a parent `Foo` doesn't keep its `children` alive, and at
some point the GC collects the seemingly dead arrays.

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

ag0ae...@gmail.com changed:

   What|Removed |Added

 CC||ag0ae...@gmail.com

--- Comment #1 from ag0ae...@gmail.com ---
(In reply to bb.temp from comment #0)
> So far I'm here but it doesn't capture the essence of the problem.
> 
> ---
[...]
> ---

That code segfaults for me. Is that what you see, too?

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

--- Comment #8 from bb.t...@gmx.com ---
(In reply to ag0aep6g from comment #7)
> Here's a reduction that segfaults reliably for me with -release -O -inline:
> 
> extern(C) void* calloc(size_t, size_t) nothrow pure;
> 
> void main()
> {
> {
> File file_;
> nop();
> }
> 
> auto scache = StringCache(1);
> foreach (nodePointer; scache.buckets)
> {
> if (nodePointer !is null) new Object;
> }
> }
> 
> struct File
> {
> ~this() {}
> }
> 
> void nop() {}
> 
> struct StringCache
> {
> this(size_t bucketCount)
> {
> buckets = (cast(void**) calloc(8, bucketCount))[0 .. bucketCount];
> }
> 
> void*[] buckets;
> }
> 

Yes that's it. Thx much for your patience.

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

bb.t...@gmx.com changed:

   What|Removed |Added

   Severity|normal  |regression

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

--- Comment #4 from ag0ae...@gmail.com ---
I think this is a bug in libdparse.

Its `StringCache` allocates space for `buckets`, but doesn't null the pointers.
On destruction it then tries to `free` the garbage pointers in there.

https://github.com/Hackerpilot/libdparse/blob/8230f207912b40a46e5eae84e50ee59215b7c67f/src/dparse/lexer.d#L2009

Could you try adding `buckets[] = null;` after that line, then rebuild
libdparse, and see if your project still crashes?

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

--- Comment #5 from ag0ae...@gmail.com ---
(In reply to ag0aep6g from comment #4)
> I think this is a bug in libdparse.
> 
> Its `StringCache` allocates space for `buckets`, but doesn't null the
> pointers. On destruction it then tries to `free` the garbage pointers in
> there.

Forget that. It's using calloc, not malloc, so it should be all zeros already.

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

--- Comment #7 from ag0ae...@gmail.com ---
Here's a reduction that segfaults reliably for me with -release -O -inline:

extern(C) void* calloc(size_t, size_t) nothrow pure;

void main()
{
{
File file_;
nop();
}

auto scache = StringCache(1);
foreach (nodePointer; scache.buckets)
{
if (nodePointer !is null) new Object;
}
}

struct File
{
~this() {}
}

void nop() {}

struct StringCache
{
this(size_t bucketCount)
{
buckets = (cast(void**) calloc(8, bucketCount))[0 .. bucketCount];
}

void*[] buckets;
}


(In reply to bb.temp from comment #6)
> Yes. I confirm that the fix you suggested in libdparse works.
> 
> But now I don't know whom the bug belongs to...
> Was it accidental that the program worked without -inline and without the
> libdparse fix ?!

I was mistaken. The bug I saw in libdparse is not there. My "fix" probably just
masks the issue somehow.

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

--- Comment #3 from bb.t...@gmx.com ---
(In reply to ag0aep6g from comment #2)
> (In reply to bb.temp from comment #0)
> > So far I'm here but it doesn't capture the essence of the problem.
> > 
> > ---
> [...]
> > ---
> 
> As far as I can tell, everything works as expected in that code.
> 
> The different `children` arrays are GC allocated (via ~=), but the `Foo`s
> themselves are not. So a parent `Foo` doesn't keep its `children` alive, and
> at some point the GC collects the seemingly dead arrays.

Take care with the small sample. I've written that <>, it was just an attempt. So far it just helped to show that it's
necessary to add the ranges to the GC, which I've done to the real program.

Despite of this in the real program it's still the same, if I call
'write(slb.serialize)':

- with '-inline': stdout is empty.
- without: stdout is filled

When you consider those two facts it really looks that the inliner does
something wrong.

--


[Issue 15272] [2.069-rc2,inline] nothing written to output when -inline is set

2015-11-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15272

--- Comment #6 from bb.t...@gmx.com ---
(In reply to ag0aep6g from comment #4)
> I think this is a bug in libdparse.
> 
> Its `StringCache` allocates space for `buckets`, but doesn't null the
> pointers. On destruction it then tries to `free` the garbage pointers in
> there.
> 
> https://github.com/Hackerpilot/libdparse/blob/
> 8230f207912b40a46e5eae84e50ee59215b7c67f/src/dparse/lexer.d#L2009
> 
> Could you try adding `buckets[] = null;` after that line, then rebuild
> libdparse, and see if your project still crashes?

Yes. I confirm that the fix you suggested in libdparse works.

But now I don't know whom the bug belongs to...
Was it accidental that the program worked without -inline and without the
libdparse fix ?!

--