After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 606180 - foo-1.0.tgir generate fail on Sparc
foo-1.0.tgir generate fail on Sparc
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
2.23.x
Other opensolaris
: Normal critical
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
: 606317 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-01-06 04:03 UTC by Halton Huo
Modified: 2015-02-07 16:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
diff file of foo-1.0.tgir compared with amd64 and sparc (18.80 KB, text/plain)
2010-01-06 04:17 UTC, Halton Huo
  Details
[ginfo] Correctly cast to a CommonBlob when looking up embedded types (2.63 KB, patch)
2010-01-07 21:16 UTC, Colin Walters
committed Details | Review

Description Halton Huo 2010-01-06 04:03:49 UTC
Build gobject-introspection 0.6.7 tarball or git-master on OpenSolaris sparc box, I always get following error:

[...]
../../tools/g-ir-generate --includedir=. --includedir=../../gir foo-1.0.typelib -o foo-1.0.tgir
**
ERROR:ginfo.c:287:g_base_info_get_name: code should not be reached
make[3]: *** [foo-1.0.tgir] Abort (core dumped)
make[3]: *** Deleting file `foo-1.0.tgir'

This issue does not happen on i386 and amd64 box. I think it might be sparc specific.
Comment 1 Halton Huo 2010-01-06 04:17:04 UTC
Created attachment 150880 [details]
diff file of foo-1.0.tgir compared with amd64 and sparc

The diff file shows error happens when parsing callback function do_foo. 

With debugging, the interface type is not GI_INFO_TYPE_CALLBACK and goes to line 404. Which is clearly wrong.

tools/generate.c
----------------
 400   interface = g_type_info_get_interface (type);
 401   if (interface && g_base_info_get_type(interface) == GI_INFO_TYPE_CALLBACK     )
 402     write_callback_info (namespace, (GICallbackInfo *)interface, file);
 403   else
 404     write_type_info (namespace, type, file);
Comment 2 Halton Huo 2010-01-06 04:53:04 UTC
I confirm this issue happens between 0.6.5 and 0.6.6 release.
Comment 3 Halton Huo 2010-01-06 09:00:06 UTC
It might be related with ending issue.

I print rinfo->typelib->data[rinfo->offset..rinfo->offset+7] in g_type_info_get_interface() of line 1002 when parsing function do_foo.

ginfo.c
---------
 997 g_type_info_get_interface (GITypeInfo *info)
 998 {
 999   GIRealInfo *rinfo = (GIRealInfo *)info;
1000   SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset];
1001 
1002   if (rinfo->type_is_embedded)

On sparc
[3572] = '\0'
[3573] = '\002'
[3574] = '\0'
[3575] = '\0'
[3576] = '\0'
[3577] = '\0'
[3578] = '\015'
[3579] = '|'

on x86
[3572] = '\002'
[3573] = '\0'
[3574] = '\0'
[3575] = '\0'
[3576] = '|'
[3577] = '\015'
[3578] = '\0'
[3579] = '\0'

It cause the variable type->offset is set to 131072U, which is incorrect. Any idea?
Comment 4 Colin Walters 2010-01-07 16:22:46 UTC
Scrolling through the commits from 0.6.5 to 0.6.6, f8693bda3775f6339f38a1 looks like a probable candidate, but I'm not seeing offhand the problem there.
Comment 5 Colin Walters 2010-01-07 16:43:11 UTC
(In reply to comment #3)
> It might be related with ending issue.
> 
> I print rinfo->typelib->data[rinfo->offset..rinfo->offset+7] in
> g_type_info_get_interface() of line 1002 when parsing function do_foo.

That's expected as far as I understand it (http://c-faq.com/struct/bitfield0.html).  The interesting data point is whether "print blob->has_embedded_type" returns 1 or not.
Comment 6 Colin Walters 2010-01-07 16:47:37 UTC
*** Bug 606317 has been marked as a duplicate of this bug. ***
Comment 7 Colin Walters 2010-01-07 16:48:17 UTC
See 606317 for the powerpc equivalent, which would seem to increase the likelihood of this being endianness related somehow.
Comment 8 Colin Walters 2010-01-07 21:16:51 UTC
Created attachment 150998 [details] [review]
[ginfo] Correctly cast to a CommonBlob when looking up embedded types

When looking at an embedded type (e.g. a Callback after a Field), the
offset we put in the info structure was to the CallbackBlob itself.

However the code in g_type_info_get_interface assumed that the offset
was to a SimpleTypeBlob, which it wasn't.
Comment 9 Halton Huo 2010-01-08 02:06:47 UTC
(In reply to comment #8)
> Created an attachment (id=150998) [details] [review]
> [ginfo] Correctly cast to a CommonBlob when looking up embedded types
> 
> When looking at an embedded type (e.g. a Callback after a Field), the
> offset we put in the info structure was to the CallbackBlob itself.
> 
> However the code in g_type_info_get_interface assumed that the offset
> was to a SimpleTypeBlob, which it wasn't.

I confirmed this patch make build pass under sparc 64-bit and 32-bit.
Comment 10 Tomeu Vizoso 2010-01-08 21:26:54 UTC
Review of attachment 150998 [details] [review]:

Looks great, thanks!
Comment 11 André Klapper 2015-02-07 16:53:39 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]