Thread overview
[Issue 5241] New: dmd: ABI breakage/regression
Nov 19, 2010
nfxjfg@gmail.com
Nov 19, 2010
nfxjfg@gmail.com
Nov 19, 2010
nfxjfg@gmail.com
[Issue 5241] dmd: ABI breakage/regression (TypeInfo.toString() returns partially corrupted string)
Jan 07, 2011
nfxjfg@gmail.com
Jan 07, 2011
Brad Roberts
Feb 11, 2011
Walter Bright
November 19, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5241

           Summary: dmd: ABI breakage/regression
           Product: D
           Version: D1
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: nfxjfg@gmail.com


--- Comment #0 from nfxjfg@gmail.com 2010-11-19 08:19:30 PST ---
At some point, both dmd and Phobos1 added a new member to TypeInfo_Struct: m_flags.

The way dmd handles this causes an ABI breakage: dmd will use the _calculated_ size of the struct to calculate the offset of the name string. After that, dmd _unconditionally_ writes the new m_flags field, and writes it at the same offset where the name string is supposed to start.

As a result, TypeInfo names for structs are broken. The first 4 items of typeid(somestruct).toString() will contain garbage. I'm not really sure why after these 4 bytes, the expected string starts. Either I got it wrong, or the backend data segment writer does strange things?

The problem doesn't appear if the object.d[i] contains the proper m_align. E.g.
compare:
http://www.dsource.org/projects/phobos/browser/branches/phobos-1.x/phobos/object.d#L141
http://www.dsource.org/projects/tango/browser/trunk/object.di#L163 (WARNING:
BSD LICENSED CODE)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 19, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5241



--- Comment #1 from nfxjfg@gmail.com 2010-11-19 08:20:24 PST ---
(In reply to comment #0)
> At some point, both dmd and Phobos1 added a new member to TypeInfo_Struct: m_flags.

Damn, that should be m_align.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 19, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5241


nfxjfg@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #2 from nfxjfg@gmail.com 2010-11-19 08:45:57 PST ---
Lazy patch:

diff --git a/idgen.c b/idgen.c
index 023d8a9..c0cfc0b 100644
--- a/idgen.c
+++ b/idgen.c
@@ -232,6 +232,8 @@ Msgtable msgtable[] =
     // varargs implementation
     { "va_argsave_t", "__va_argsave_t" },
     { "va_argsave", "__va_argsave" },
+
+    { "m_align" },
 };


diff --git a/typinf.c b/typinf.c
index 906795a..ab9d87b 100644
--- a/typinf.c
+++ b/typinf.c
@@ -593,8 +593,11 @@ void TypeInfoStructDeclaration::toDt(dt_t **pdt)
     // uint m_flags;
     dtdword(pdt, tc->hasPointers());

-    // uint m_align;
-    dtdword(pdt, tc->alignsize());
+    if (Type::typeinfostruct->search(NULL, Id::m_align, 0))
+    {
+        // uint m_align;
+        dtdword(pdt, tc->alignsize());
+    }

 #if DMDV2
     // xgetMembers

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5241


nfxjfg@gmail.com changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5241


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |braddr@puremagic.com
         Resolution|WONTFIX                     |


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 11, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5241


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2011-02-11 03:01:12 PST ---
https://github.com/D-Programming-Language/dmd/commit/8621e5960fb80a402069250aa620f75291d383e5

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------