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 728123 - glib2 @2.40.0 issues a "Got weird mach timebase info" error (Macports, PPC)
glib2 @2.40.0 issues a "Got weird mach timebase info" error (Macports, PPC)
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: general
2.40.x
Other Mac OS
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 728694 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2014-04-13 17:31 UTC by f2405
Modified: 2020-07-07 00:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Mac OS X crash report (26.89 KB, application/octet-stream)
2014-04-13 17:31 UTC, f2405
  Details
Fix g_get_monotonic_time() where the fraction is not 1/1 (3.98 KB, patch)
2014-04-22 15:58 UTC, Misty De Meo
none Details | Review
Updated g_get_monotonic_time for non-Intel Darwin (3.98 KB, patch)
2014-05-02 03:51 UTC, Misty De Meo
none Details | Review
clean up mach time handling (2.50 KB, patch)
2014-12-18 20:01 UTC, holin
none Details | Review
clean up mach time handling (2.76 KB, patch)
2014-12-19 08:54 UTC, holin
none Details | Review

Description f2405 2014-04-13 17:31:36 UTC
Created attachment 274205 [details]
Mac OS X crash report

While starting up inkscape, I obtain the following error message while crashing:

-------------------

$ inkscape

(inkscape:99961): GLib-GObject-WARNING **: gvalue.c:181: cannot initialize GValue with type 'guint', the value has already been initialized as '-g-type-private--IFaceHolder'

(inkscape:99961): GLib-GObject-WARNING **: unable to set property 'digits' of type 'guint' from value of type 'guint'

(inkscape:99961): GLib-ERROR **: Got weird mach timebase info of 1000000000/33329426.  Please file a bug against GLib.
Trace/BPT trap

-------------------

Some ideas?
Comment 1 Allison Karlitskaya (desrt) 2014-04-13 21:57:18 UTC
Fascinating!  Thanks for the report.

Can you please tell me what your exact system configuration is?  What model of Mac and what OS version, particularly...

Cheers
Comment 2 f2405 2014-04-13 23:29:51 UTC
I is a good old (and still fit) "PowerBook G4" running "Leopard":

$ uname -mpv
Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_PPC Power Macintosh powerpc

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.5.8
BuildVersion:	9L31a

$ system_profiler | grep "Processor Name"
      Processor Name: PowerPC G4  (3.3)

$ machine
ppc7450

Maybe it is worth noting that ppc operates in big endian mode.
Comment 3 Allison Karlitskaya (desrt) 2014-04-13 23:48:16 UTC
This OS version has been unsupported for 2 years...
Comment 4 f2405 2014-04-14 17:00:48 UTC
(In reply to comment #3)
> This OS version has been unsupported for 2 years...
Does this mean you will ignore the bug? At Macports they have directed me to you as gnome developer. Besides I need to say that the problem was not present until about half a year ago (the last time I was using inkscape). Some glib2 updates in between seem to have brought the "weird mach timebase info" error. What do you think?
Comment 5 Dan Winship 2014-04-14 17:20:07 UTC
(In reply to comment #3)
> This OS version has been unsupported for 2 years...

but it's probably the latest one that exists for ppc?
Comment 6 Allison Karlitskaya (desrt) 2014-04-14 17:27:59 UTC
(In reply to comment #5)
> but it's probably the latest one that exists for ppc?

Yes.  It is.

I didn't consider this facet of our 'new approach to portability'.  I wonder how many people are still using insecure/unpatched version of Mac OS on PPC boxes...
Comment 7 f2405 2014-04-21 21:31:34 UTC
(In reply to comment #6)
> ...
> 
> I didn't consider this facet of our 'new approach to portability'.  I wonder
> how many people are still using insecure/unpatched version of Mac OS on PPC
> boxes...

There is a very helpful contribution on this "Got weird mach timebase info" issue on the macports portal: https://trac.macports.org/ticket/43346#comment:2

The poster has localized the problem inside the function g_get_monotonic_time() in glib/gmain.c and proposes a long double computation for the mach tick period on PPC CPUs (instead of a 64bit integer division). Please see his/her macports patch proposal: https://trac.macports.org/attachment/ticket/43346/patch-glib-gmain-c.diff

I think some PPC related work-around for this issue should be added to glib2! Thanks for your effort!
Comment 8 Allison Karlitskaya (desrt) 2014-04-22 13:01:12 UTC
*** Bug 728694 has been marked as a duplicate of this bug. ***
Comment 9 Allison Karlitskaya (desrt) 2014-04-22 13:21:58 UTC
I think there's probably not much harm in adding a separate path to support this case, but I'd rather not go through the process of converting an int to floating point to perform a multiplication and then back again on systems where we don't need it (ie: the 99% case).

Is there some symbol that is #define'd only on PPC Mac OS that I can #ifdef for in order to do a separate path?


However: note that this will probably only be a temporary fix.  There are some APIs in newer versions of Mac OS that we are looking forward to relying on and we do plan to use them once the older versions fall out of support... at that point, it won't be a simple matter of doing some math in order to get things working again...

There comes a point where we have to stop caring about old versions and that typically coincides with when the OS vendor does the same.  Apple abandoned 10.5 (and PPC) long ago...  It's always possible that you can use older versions of GLib, of course, just as you continue to use older versions of Mac OS...
Comment 10 Misty De Meo 2014-04-22 15:58:49 UTC
Created attachment 274897 [details] [review]
Fix g_get_monotonic_time() where the fraction is not 1/1

Since, as I mentioned in #728694, this is also an issue on other non-Intel platforms (read: iOS), I'd rather not special-case PowerPC or make additional assumptions. Instead, why not special-case if the fraction is 1/1, then also provide an alternate codepath that doesn't assume anything about the platform on which it's being run?

I've attached a sample patch that does this.
Comment 11 Misty De Meo 2014-05-02 03:51:09 UTC
Created attachment 275596 [details] [review]
Updated g_get_monotonic_time for non-Intel Darwin

I realized there was a minor typo in the previous patch; I've updated it. I've tested it on PowerPC and Intel Macs with success. The following simple test program returns consistent results across Linux, PPC/Darwin and Intel/Darwin:

#include <stdio.h>
#include <unistd.h>
 
#include <glib.h>
 
int main()
{
    gint64 then = g_get_monotonic_time();
    sleep(1);
    gint64 now = g_get_monotonic_time();
    printf("%lli\n", now - then);
}
Comment 12 f2405 2014-05-05 07:10:47 UTC
(In reply to comment #11)
> I realized there was a minor typo in the previous patch; I've updated it. I've
> tested it on PowerPC and Intel Macs with success. ...
Thanks! It would be great if the maintainer could test this patch for g_get_monotonic_time().
Comment 13 f2405 2014-05-10 15:51:27 UTC
Have applied the patch for gmain.c proposed under https://bug728123.bugzilla-attachments.gnome.org/attachment.cgi?id=275596 on foot on my MacOSX 10.5.8 PPC.

Have checked my subsequent glib2 build using the code (saved as g_get_monotonic_time.c and compiled calling gcc g_get_monotonic_time.c -Wall -o g_get_monotonic_time `pkg-config --cflags --
libs glib-2.0`) provided under https://bugzilla.gnome.org/show_bug.cgi?id=728123#c11 - works well:

$ ./g_get_monotonic_time
1000071

This is the time in microsecond between two calls of g_get_monotonic_time() with one second pause. Depending on processor load, this time may vary:

$ ./g_get_monotonic_time
1001127

To me it appears as if the patch can be officially adopted.

BTW, now I again can use inkscape, which was that application I previously could not launch...
Comment 14 Misty De Meo 2014-06-06 17:52:01 UTC
Just wanted to check in on the status of this - sorry to bump.

This patch has now been applied locally by both the Tigerbrew (PPC arm of Homebrew) and Macports package managers for about 6 weeks, and it's been tested by a number of users without issue at this point, on both PPC and Intel.
Comment 15 Allison Karlitskaya (desrt) 2014-06-06 18:43:52 UTC
I've been thinking about this issue.

If most people are using GLib on PPC via these package managers (which is almost certainly the case) and if these package managers already carry the patch, then I'm happy to leave well enough alone.

I don't want to add this codepath unless we'll have a mechanism for regularly testing it, and we don't have that.

I hope everyone is OK with that solution...

Thank you, Misty, for writing this patch to help those still on PPC, and I'm happy that it will be useful for that audience.
Comment 16 Misty De Meo 2014-06-06 18:45:20 UTC
I understand you don't actively support PPC anymore, but this also fixes other non-Intel platforms. e.g., glib currently won't work on iOS/ARM, due to the same issue that blocks PPC.
Comment 17 Allison Karlitskaya (desrt) 2014-06-06 20:09:56 UTC
I didn't appreciate that before.

http://iosdeveloperzone.com/2011/05/03/quick-performance-measurements/ indeed appears to claim that 125/3 was observed on an iPhone.
Comment 18 Misty De Meo 2014-06-06 22:42:05 UTC
Yes, I believe it's CPU-dependent on ARM (if not device-dependent as it is on PPC); it would not surprise me if other values occur as well.
Comment 19 f2405 2014-06-07 20:23:42 UTC
If I find some time I will check on my son's raspberry pi if this popular ARM-based machine is also affected by the "Got weird mach timebase info" error. It should, I think.
Comment 20 Misty De Meo 2014-06-07 20:26:42 UTC
This issue is specific to the Darwin timebase function, so unless your son's raspberry pi runs Darwin I doubt it will be affected. Thanks though!
Comment 21 holin 2014-12-18 20:01:37 UTC
Created attachment 293003 [details] [review]
clean up mach time handling

The current code in gmain.c looks rather odd. Maybe you could consider something along the lines of the attachment. I'd prefer integer arithmetics in this case.
Comment 22 holin 2014-12-19 08:54:52 UTC
Created attachment 293030 [details] [review]
clean up mach time handling

Update the patch with soothing comments and remove typoed extra call to mach_absolute_time
Comment 23 holin 2014-12-19 09:00:00 UTC
I tested the above patch on darwin9/ppc and darwin10/x86. Also tested x86 by adding a bogus 10000000:10000001 timebase to exercise the muldiv codepath. Someone might prefer to special case numerator==1 and just do the division then.
Comment 24 John Ralls 2015-01-04 19:23:12 UTC
Review of attachment 293030 [details] [review]:

I've tested this on a PowerMini running Leopard and it works fine there. I recommend committing it.
Comment 25 venture37 2015-02-04 14:20:44 UTC
I tested the "clean up mach time handling" diff on Tiger/PowerPC running on a PowerMac G4. I was previously hitting this bug when building gstreamer0.10

g-ir-scanner: link: ../libtool --mode=link --tag=CC gcc -std=gnu99 -o /private/tmp/multimedia/gstreamer0.10/work/gstreamer-0.10.36/gst/tmp-introspecteg9Qrj/Gst-0.10 -export-dynamic -isystem /usr/include -I/usr/pkg/include -I/usr/include -pipe -O2 -I/usr/pkg/include -I/usr/include -L/usr/pkg/lib -L/usr/lib /private/tmp/multimedia/gstreamer0.10/work/gstreamer-0.10.36/gst/tmp-introspecteg9Qrj/Gst-0.10.o -L. libgstreamer-0.10.la -L/usr/pkg/lib -lgio-2.0 -lgmodule-2.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl -lxml2
libtool: link: gcc -std=gnu99 -o /private/tmp/multimedia/gstreamer0.10/work/gstreamer-0.10.36/gst/tmp-introspecteg9Qrj/.libs/Gst-0.10 -isystem /usr/include -I/tmp/multimedia/gstreamer0.10/work/.buildlink/include -pipe -O2 /private/tmp/multimedia/gstreamer0.10/work/gstreamer-0.10.36/gst/tmp-introspecteg9Qrj/Gst-0.10.o  -L/tmp/multimedia/gstreamer0.10/work/.buildlink/lib -L. /tmp/multimedia/gstreamer0.10/work/gstreamer-0.10.36/gst/.libs/libgstreamer-0.10.dylib -ldl /tmp/multimedia/gstreamer0.10/work/.buildlink/lib/libgio-2.0.dylib -lresolv /tmp/multimedia/gstreamer0.10/work/.buildlink/lib/libgobject-2.0.dylib /tmp/multimedia/gstreamer0.10/work/.buildlink/lib/libffi.dylib /tmp/multimedia/gstreamer0.10/work/.buildlink/lib/libgmodule-2.0.dylib /tmp/multimedia/gstreamer0.10/work/.buildlink/lib/libgthread-2.0.dylib /tmp/multimedia/gstreamer0.10/work/.buildlink/lib/libglib-2.0.dylib /tmp/multimedia/gstreamer0.10/work/.buildlink/lib/libpcre.dylib /tmp/multimedia/gstreamer0.10/work/.buildlink/lib/libintl.dylib -lc /tmp/multimedia/gstreamer0.10/work/.buildlink/lib/libxml2.dylib /tmp/multimedia/gstreamer0.10/work/.buildlink/lib/libz.dylib /tmp/multimedia/gstreamer0.10/work/.buildlink/lib/liblzma.dylib -lpthread /usr/lib/libiconv.dylib -lm

(<unknown>:28162): GLib-ERROR **: Got weird mach timebase info of 1000000000/41655802.  Please file a bug against GLib.
Command '['/private/tmp/multimedia/gstreamer0.10/work/gstreamer-0.10.36/gst/tmp-introspecteg9Qrj/Gst-0.10', '--introspect-dump=/private/tmp/multimedia/gstreamer0.10/work/gstreamer-0.10.36/gst/tmp-introspecteg9Qrj/functions.txt,/private/tmp/multimedia/gstreamer0.10/work/gstreamer-0.10.36/gst/tmp-introspecteg9Qrj/dump.xml']' returned non-zero exit status -5
Makefile:1784: recipe for target 'Gst-0.10.gir' failed


This patch resolved the issue.
Comment 26 PHO 2015-02-10 01:45:12 UTC
I tested attachment 293030 [details] [review] too on MacOS X 10.5 running on PowerMac G5. After applying the patch the problem completely went away. I hope it will be merged.
Comment 27 Ryan Schmidt 2016-08-18 08:35:30 UTC
Can this fix be committed, please?
Comment 28 Patrick Welche 2016-11-22 16:45:23 UTC
ping?
Comment 29 Ryan Schmidt 2018-03-15 17:21:55 UTC
We've been using this patch in MacPorts since May 2014:

https://github.com/macports/macports-ports/commit/91a3a2eb91b3ea62813471bdb280fe2a56491698

It would be great if it could be committed so that non-MacPorts users could benefit from it too.
Comment 30 Misty De Meo 2018-03-15 18:06:49 UTC
Tigerbrew has also been using this patch since 2014. It would be great to get this in an official Glib release.
Comment 31 GNOME Infrastructure Team 2018-05-24 16:27:01 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/858.
Comment 32 Misty De Meo 2020-07-06 23:57:36 UTC
Remember how I mentioned this breaks iOS? :)

On the new ARM Macs, the timebase unit is also not 1/1 - just like on PowerPC Mac OS and ARM iOS. This time code will not work on ARM Macs. The patch I proposed in 2014 is still valid and should fix the issue by making use of the documented timebase struct to access the value, which is the way that Apple recommend susing this value.

It appears this code hasn't changed much in the past two years, so this bug still exists: https://github.com/GNOME/glib/blob/18b89c1486176568e0d0e04319a4b1bbfc0988fb/glib/gmain.c#L2898
Comment 33 Misty De Meo 2020-07-07 00:01:34 UTC
Sorry, totally blanked on the migration. Posted on gitlab.