Thread overview | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 25, 2018 BetterC is so much bugs, is Walter really use it in DMD? | ||||
---|---|---|---|---|
| ||||
================== 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. |
October 26, 2018 Re: BetterC is so much bugs, is Walter really use it in DMD? | ||||
---|---|---|---|---|
| ||||
Posted in reply to test | On 26/10/2018 1:47 AM, test wrote:
snip
> 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.
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).
|
October 25, 2018 Re: BetterC is so much bugs, is Walter really use it in DMD? | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | 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.
|
October 26, 2018 Re: BetterC is so much bugs, is Walter really use it in DMD? | ||||
---|---|---|---|---|
| ||||
Posted in reply to test | 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); } |
October 25, 2018 Re: BetterC is so much bugs, is Walter really use it in DMD? | ||||
---|---|---|---|---|
| ||||
Posted in reply to test | 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.
|
October 26, 2018 Re: BetterC is so much bugs, is Walter really use it in DMD? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On 26/10/2018 2:51 AM, Adam D. Ruppe wrote:
> 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.
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).
|
October 25, 2018 Re: BetterC is so much bugs, is Walter really use it in DMD? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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:
>> 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.
Walter develop betterC for the conversion of the back end.
|
October 25, 2018 Re: BetterC is so much bugs, is Walter really use it in DMD? | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | 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 ;/
|
October 25, 2018 Re: BetterC is so much bugs, is Walter really use it in DMD? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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 |
October 26, 2018 Re: BetterC is so much bugs, is Walter really use it in DMD? | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | 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 Thanks 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. |
Copyright © 1999-2021 by the D Language Foundation