digitalmars.D - BetterC is so much bugs, is Walter really use it in DMD?
- test (117/117) Oct 25 2018 ==================
- rikki cattermole (6/11) Oct 25 2018 I just compared the assembly, there isn't anything terribly different
- test (38/43) Oct 25 2018 ==============
- rikki cattermole (19/19) Oct 25 2018 After minimizing it myself (at the end), I think that you're running
- SrMordred (5/24) Oct 25 2018 I started to make some BetterC libs and fall on this same bug.
- test (17/28) Oct 25 2018 Thanks for share this.
- Nicholas Wilson (2/4) Oct 26 2018 Not long: https://github.com/dlang/dmd/pull/8872
- Adam D. Ruppe (7/8) Oct 25 2018 No, the compiler is built as ordinary D. betterC is just a toy
- rikki cattermole (3/12) Oct 25 2018 Its not TLS at fault. See my minimized code as an example.
- 12345swordy (2/10) Oct 25 2018 Walter develop betterC for the conversion of the back end.
- Jacob Carlborg (4/5) Oct 25 2018 The operating system is initializing TLS.
================== import core.stdc.stdio; version(D_BetterC) { extern(C) void main() { start; } } else { void main(){ start; } } struct Node { disable this(); disable this(this); int _count = 0; this(int i){ _count =i ; } void add(){ _count++; } void dec(){ _count--; } } struct Proxy { Node* p ; this(Node* n){ assert(n); p = n ; p.add; } ~this() { printf("~this(%x, p=%x)\n", &this, p) ; drop ; } void opAssign(ref Proxy other){ printf("opAssign(ref this=%x, %x), other=%x, %x\n", &this, p, &other, other.p) ; drop ; assert(other.p); p = other.p ; p.add ; } this(this) { printf("this(this)\n") ; if( p ) p.add ; } void opAssign(Proxy other){ printf("opAssign(this=%x, %x), other=%x, %x\n", &this, p, &other, other.p) ; drop; if( other.p ) { p = other.p ; p.add ; } } void drop(){ if( p ) { p.dec; } p = null ; } } __gshared Node n = Node(0) ; __gshared ThreadS s ; Proxy proxy; void start(){ run(null); } void run(void* data) { printf(" ========> run.enter\n") ; proxy = runFiber(&n); printf(" ========> run.exit\n") ; } ref auto runFiber(Node* p){ auto fiber = ThreadS.getThisS.getFiber(p); return fiber ; } struct ThreadS { static auto getThisS(){ return &s; } ref auto getFiber(Node* p) { return fromPointer(p) ; } } ref auto fromPointer(Node* p) { return Proxy(p) ; } version(D_BetterC) extern(C) { __gshared int _d_eh_personality(int, int, size_t, void*, void*) { return 0;}; __gshared void _d_eh_resume_unwind(void*) { return ;}; } ================================= with -BetterC ========> run.enter ~this(c7da5060, p=3e40030) opAssign(this=b40574b0, 0), other=c7da5030, 0 ~this(c7da5030, p=0) ========> run.exit without -BetterC ========> run.enter opAssign(this=ffd1ab60, 0), other=885b32f0, 8f8da960 ~this(885b32f0, p=8f8da960) ========> run.exit Take me 16 hours to find this bug, Is your people really use it to build compiler ? Really is a good way to waste time to use this.
Oct 25 2018
On 26/10/2018 1:47 AM, test wrote: snipTake me 16 hours to find this bug, Is your people really use it to build compiler ? Really is a good way to waste time to use this.I just compared the assembly, there isn't anything terribly different for Proxy.__dtor being called. So I would say that you have found some corner case bug. Please try to minimize it + report it to bugzilla (issues.dlang.org).
Oct 25 2018
On Thursday, 25 October 2018 at 13:00:51 UTC, rikki cattermole wrote:I just compared the assembly, there isn't anything terribly different for Proxy.__dtor being called. So I would say that you have found some corner case bug. Please try to minimize it + report it to bugzilla (issues.dlang.org).============== import core.stdc.stdio; version(D_BetterC) { extern(C) void main() { start; } } else { void main(){ start; } } struct Proxy { this(bool i){} ~this() { printf("~this(%x)\n", &this) ; } void opAssign(Proxy other){ printf("opAssign(this=%x), other=%x\n", &this, &other) ; } } Proxy proxy; void start(){ proxy = getProxy(); } ref auto getProxy(){ auto proxy = Proxy(1); return proxy ; } version(D_BetterC) extern(C) { __gshared int _d_eh_personality(int, int, size_t, void*, void*) { return 0;}; __gshared void _d_eh_resume_unwind(void*) { return ;}; } ==================== still can not register, please help me to report.
Oct 25 2018
After minimizing it myself (at the end), I think that you're running into https://issues.dlang.org/show_bug.cgi?id=18457 struct Node {} struct Proxy { ~this() { count++; } Node* n; } ref auto something(Node* p){ auto value = Proxy(p); return value; } __gshared int count; extern(C) void main() { Node n; something(&n); assert(count == 1); }
Oct 25 2018
On Thursday, 25 October 2018 at 13:28:22 UTC, rikki cattermole wrote:After minimizing it myself (at the end), I think that you're running into https://issues.dlang.org/show_bug.cgi?id=18457 struct Node {} struct Proxy { ~this() { count++; } Node* n; } ref auto something(Node* p){ auto value = Proxy(p); return value; } __gshared int count; extern(C) void main() { Node n; something(&n); assert(count == 1); }I started to make some BetterC libs and fall on this same bug. It make it impossible to properly control resources lifetime if you return it from functions ;/
Oct 25 2018
On Thursday, 25 October 2018 at 13:28:22 UTC, rikki cattermole wrote:After minimizing it myself (at the end), I think that you're running into https://issues.dlang.org/show_bug.cgi?id=18457Thanks for share this. On Thursday, 25 October 2018 at 15:48:43 UTC, SrMordred wrote:I started to make some BetterC libs and fall on this same bug. It make it impossible to properly control resources lifetime if you return it from functions ;/Yes, is is make the refCount release not working, already 8 month passed, I am curious how many time take before it fixed. And there is more bugs I can not find or minimize in betterC since the codebase is huge. A bugs is still show after I remove all "debug{ ...}" code, I get it with "-betterC -debug"(not exists if I only pass -betterC). bin/../import/std/array.d(2957): Error: TypeInfo cannot be used with -betterC On Thursday, 25 October 2018 at 13:51:16 UTC, Adam D. Ruppe wrote:No, the compiler is built as ordinary D. betterC is just a toy switch. But the bug there is that you used TLS without properly initializing it. I am kinda of the opinion that betterC should make this an error, or at least that -betterC should imply -vtls, since it is so frequently a mistake.As rikki cattermole said, this is not related to tls. and please don't make tls a error in betterC. since I use it in my product with betterC, with a tiny runtime(no typeinfo) it can working nice.
Oct 25 2018
On Friday, 26 October 2018 at 01:50:01 UTC, test wrote:Yes, is is make the refCount release not working, already 8 month passed, I am curious how many time take before it fixed.Not long: https://github.com/dlang/dmd/pull/8872
Oct 26 2018
On Friday, 26 October 2018 at 10:12:14 UTC, Nicholas Wilson wrote:On Friday, 26 October 2018 at 01:50:01 UTC, test wrote:Nice!Yes, is is make the refCount release not working, already 8 month passed, I am curious how many time take before it fixed.Not long: https://github.com/dlang/dmd/pull/8872
Oct 26 2018
On Friday, 26 October 2018 at 10:12:14 UTC, Nicholas Wilson wrote:On Friday, 26 October 2018 at 01:50:01 UTC, test wrote:This is great.Yes, is is make the refCount release not working, already 8 month passed, I am curious how many time take before it fixed.Not long: https://github.com/dlang/dmd/pull/8872
Oct 26 2018
On Thursday, 25 October 2018 at 12:47:17 UTC, test wrote:Is your people really use it to build compiler ?No, the compiler is built as ordinary D. betterC is just a toy switch. But the bug there is that you used TLS without properly initializing it. I am kinda of the opinion that betterC should make this an error, or at least that -betterC should imply -vtls, since it is so frequently a mistake.
Oct 25 2018
On 26/10/2018 2:51 AM, Adam D. Ruppe wrote:On Thursday, 25 October 2018 at 12:47:17 UTC, test wrote:Its not TLS at fault. See my minimized code as an example. -betterC seems to be calling dtor when it shouldn't be (existing known bug).Is your people really use it to build compiler ?No, the compiler is built as ordinary D. betterC is just a toy switch. But the bug there is that you used TLS without properly initializing it. I am kinda of the opinion that betterC should make this an error, or at least that -betterC should imply -vtls, since it is so frequently a mistake.
Oct 25 2018
On Thursday, 25 October 2018 at 13:51:16 UTC, Adam D. Ruppe wrote:On Thursday, 25 October 2018 at 12:47:17 UTC, test wrote:Walter develop betterC for the conversion of the back end.Is your people really use it to build compiler ?No, the compiler is built as ordinary D. betterC is just a toy switch. But the bug there is that you used TLS without properly initializing it. I am kinda of the opinion that betterC should make this an error, or at least that -betterC should imply -vtls, since it is so frequently a mistake.
Oct 25 2018
On 2018-10-25 15:51, Adam D. Ruppe wrote:But the bug there is that you used TLS without properly initializing it.The operating system is initializing TLS. -- /Jacob Carlborg
Oct 25 2018