Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
September 02, 2008 [Issue 2328] New: setTypeInfo in gc.d backwards. | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2328 Summary: setTypeInfo in gc.d backwards. Product: D Version: 2.018 Platform: All OS/Version: All Status: NEW Severity: major Priority: P2 Component: Phobos AssignedTo: bugzilla@digitalmars.com ReportedBy: dsimcha@yahoo.com According to Phobos object docs: uint flags(); Get flags for type: 1 means GC should scan for pointers This is implemented correctly. import std.stdio; void main() { writefln(typeid(uint).flags & 1); //0 writefln(typeid(uint*).flags & 1); //1 writefln(typeid(void*).flags & 1); //1 writefln(typeid(float).flags & 1); //0 } However, source code to setTypeInfo: void setTypeInfo(TypeInfo ti, void* p) { if (ti.flags() & 1) hasNoPointers(p); else hasPointers(p); } The if statement in this code is clearly backwards. -- |
September 02, 2008 Re: [Issue 2328] New: setTypeInfo in gc.d backwards. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | d-bugmail@puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=2328
>
> Summary: setTypeInfo in gc.d backwards.
> Product: D
> Version: 2.018
> Platform: All
> OS/Version: All
> Status: NEW
> Severity: major
> Priority: P2
> Component: Phobos
> AssignedTo: bugzilla@digitalmars.com
> ReportedBy: dsimcha@yahoo.com
>
>
> According to Phobos object docs:
>
> uint flags();
> Get flags for type: 1 means GC should scan for pointers
>
> This is implemented correctly.
>
> import std.stdio;
>
> void main() {
> writefln(typeid(uint).flags & 1); //0
> writefln(typeid(uint*).flags & 1); //1
> writefln(typeid(void*).flags & 1); //1
> writefln(typeid(float).flags & 1); //0
> }
>
> However, source code to setTypeInfo:
>
> void setTypeInfo(TypeInfo ti, void* p)
> {
> if (ti.flags() & 1)
> hasNoPointers(p);
> else
> hasPointers(p);
> }
>
> The if statement in this code is clearly backwards.
I'm fairly certain that the doc comment is simply wrong. Last time I checked, the flag was 1 for "has no pointers" as per the implementation. I'd actually prefer it to work as the comment suggests, however.
|
September 02, 2008 Re: [Issue 2328] New: setTypeInfo in gc.d backwards. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | == Quote from Sean Kelly (sean@invisibleduck.org)'s article
> d-bugmail@puremagic.com wrote:
> > http://d.puremagic.com/issues/show_bug.cgi?id=2328
> >
> > Summary: setTypeInfo in gc.d backwards.
> > Product: D
> > Version: 2.018
> > Platform: All
> > OS/Version: All
> > Status: NEW
> > Severity: major
> > Priority: P2
> > Component: Phobos
> > AssignedTo: bugzilla@digitalmars.com
> > ReportedBy: dsimcha@yahoo.com
> >
> >
> > According to Phobos object docs:
> >
> > uint flags();
> > Get flags for type: 1 means GC should scan for pointers
> >
> > This is implemented correctly.
> >
> > import std.stdio;
> >
> > void main() {
> > writefln(typeid(uint).flags & 1); //0
> > writefln(typeid(uint*).flags & 1); //1
> > writefln(typeid(void*).flags & 1); //1
> > writefln(typeid(float).flags & 1); //0
> > }
> >
> > However, source code to setTypeInfo:
> >
> > void setTypeInfo(TypeInfo ti, void* p)
> > {
> > if (ti.flags() & 1)
> > hasNoPointers(p);
> > else
> > hasPointers(p);
> > }
> >
> > The if statement in this code is clearly backwards.
> I'm fairly certain that the doc comment is simply wrong. Last time I
> checked, the flag was 1 for "has no pointers" as per the implementation.
> I'd actually prefer it to work as the comment suggests, however.
Nope, I actually tested the implementation. I didn't just assume the doc comment was right. Furthermore, I tried to write code based on the expected behavior of Phobos's setTypeInfo() and it was clearly broken. Lying to setTypeInfo() about the type fixed it. Note that I don't know if this bug exists in Tango or Phobos/D1, only that it does exist in Phobos/D2.
|
September 02, 2008 Re: [Issue 2328] New: setTypeInfo in gc.d backwards. | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsimcha | dsimcha wrote:
>>>
>>> The if statement in this code is clearly backwards.
>> I'm fairly certain that the doc comment is simply wrong. Last time I
>> checked, the flag was 1 for "has no pointers" as per the implementation.
>> I'd actually prefer it to work as the comment suggests, however.
>
> Nope, I actually tested the implementation. I didn't just assume the doc comment
> was right. Furthermore, I tried to write code based on the expected behavior of
> Phobos's setTypeInfo() and it was clearly broken. Lying to setTypeInfo() about
> the type fixed it. Note that I don't know if this bug exists in Tango or
> Phobos/D1, only that it does exist in Phobos/D2.
Oops, I was thinking of ClassInfo, which uses "&2" to represent "hasNoPointers." You're right that TypeInfo uses "&1" to represent "hasPointers." A bit confusing, so it doesn't surprise me that setTypeInfo is wrong. However, Phobos' use of this flag in the runtime code is actually correct. See internal/gc/gc.d, for example. In short, setTypeInfo should probably just be deleted, since it's both incorrect and unused.
|
January 26, 2009 [Issue 2328] setTypeInfo in gc.d backwards. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2328 dsimcha@yahoo.com changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|major |critical Version|2.018 |1.039 ------- Comment #1 from dsimcha@yahoo.com 2009-01-25 22:15 ------- No longer relevant to D2, but should still be fixed in D1. -- |
April 25, 2012 [Issue 2328] setTypeInfo in gc.d backwards. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2328 --- Comment #2 from github-bugzilla@puremagic.com 2012-04-25 01:43:15 PDT --- Commit pushed to phobos-1.x at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/e13d211422f71a681f08bf28df2c54bd7bf9dc88 fix Issue 2328 - setTypeInfo in gc.d backwards. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation