Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OS X 10.9] dyld: Symbol not found: _pthread_chdir_np #20

Open
RJVB opened this issue Oct 27, 2024 · 14 comments
Open

[OS X 10.9] dyld: Symbol not found: _pthread_chdir_np #20

RJVB opened this issue Oct 27, 2024 · 14 comments

Comments

@RJVB
Copy link

RJVB commented Oct 27, 2024

FF Dynasty 132.0 seemed to work fine for me in quick testing, so I set it up to run on a clone of the profile I use in Waterfox (G3.2.7-osxfix-eol).

It starts up OK, opening all the windows it should that even look like they do in Waterfox, but then it hangs after I've just been able to cancel the "make default browser" invitation. Launching from a terminal I see

> /path/to/FFDynasty-1320/Firefox.app/Contents/MacOS/firefox
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
2024-10-28 00:02:51.466 firefox[11376:10d03] CoreText performance note: Client called CTFontCreateWithName() using name "Lucida Grande" and got font with PostScript name "LucidaGrande". For best performance, only use PostScript names when calling this API.
2024-10-28 00:02:51.467 firefox[11376:10d03] CoreText performance note: Set a breakpoint on CTFontLogSuboptimalRequest to debug.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
[GFX1]: NextSurface returning false because of invalid mSize (0, 0).
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
console.error: "attribute_timeout: attachedFxAOAuthClients"
console.error: (new Error("attachedFxAOAuthClients targeting getter timed out after 5000ms", "resource://messaging-system/targeting/Targeting.sys.mjs", 139))
JavaScript warning: moz-extension://a4d71339-e05c-a94f-84ab-921ad5ea5077/js/Driver/Bookmarks.js, line 1642: unreachable code after return statement
dyld: lazy symbol binding failed: Symbol not found: _pthread_chdir_np
  Referenced from: /path/to/FFDynasty-1320/Firefox.app/Contents/MacOS/XUL
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _pthread_chdir_np
  Referenced from: /path/to/FFDynasty-1320/Firefox.app/Contents/MacOS/XUL
  Expected in: /usr/lib/libSystem.B.dylib

_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.

It seems quite likely that the attempted use of pthread_chdir_np() is the culprit here; they appear just before the beachball A bit strange that FF wouldn't be prepared to handle XUL crashes though...

@RJVB
Copy link
Author

RJVB commented Oct 28, 2024

@RJVB
Copy link
Author

RJVB commented Oct 29, 2024

It looks like the issue can be triggered by installing the "Video DownloadHelper" extension in a fresh profile:

https://addons.mozilla.org/en-US/firefox/addon/video-downloadhelper/

@Wowfunhappy
Copy link

It looks like the issue can be triggered by installing the "Video DownloadHelper" extension in a fresh profile:

Do I need to do anything with the addon once installed? I installed it but my Firefox is still working.

@RJVB
Copy link
Author

RJVB commented Oct 29, 2024 via email

@Wowfunhappy
Copy link

I didn't have to do anything, I just started with a new profile and only added the extension. What OS version did you try this on?

10.9. It looks like the helper application needs Mojave, do you have an older version?

If the extension can trigger that call (a priori via javascript) then a site could do it too and since the functionality is available via a syscall I would argue that there is no excuse not to fix that.

I completely agree, I was just stating that I can't personally trigger it in the way you suggested.

I get an error about another missing function (in the clock_gettime family).

That should be trivially fixable with MacPorts Legacy Support, right?

@RJVB
Copy link
Author

RJVB commented Oct 29, 2024 via email

@RJVB
Copy link
Author

RJVB commented Oct 30, 2024

In ipc/chromium/src/base/process_util_mac.mm:26 :

extern "C" {
// N.B. the syscalls are available back to 10.5, but the C wrappers
// only in 10.12.  Fortunately, 10.15 is our current baseline.
int pthread_chdir_np(const char* dir) API_AVAILABLE(macosx(10.12));
int pthread_fchdir_np(int fd) API_AVAILABLE(macosx(10.12));

And from syscall.h:

#define   SYS___pthread_chdir 348
#define   SYS___pthread_fchdir 349

The (missing) C calls are just wrappers; it should be possible to replace the declarations at line 26 with actual definitions:

int pthread_chdir_np(const char* dir)
{
    return syscall(SYS___pthread_chdir, dir);
}

int pthread_fchdir_np(int fd)
{
    return syscall(SYS___pthread_fchdir, fd);
}

Patch:
pthread_chdir.diff

While we're at it:
third_party/rust/zeitstempel/src/mac.rs:31:

extern "C" {
    fn clock_gettime_nsec_np(clock_id: clockid_t) -> u64;
}

mozglue/misc/Uptime.cpp:77:

Maybe<uint64_t> NowExcludingSuspendMs() {
#if !defined(MAC_OS_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_10_12
  struct timespec ts = {0};
  return Some(clock_gettime_missing(CLOCK_UPTIME_RAW, &ts)/ kNSperMS);
#else
  return Some(clock_gettime_nsec_np(CLOCK_UPTIME_RAW) / kNSperMS);
#endif
}

Maybe<uint64_t> NowIncludingSuspendMs() {
#if !defined(MAC_OS_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_10_12
  struct timespec ts = {0};
  return Some(clock_gettime_missing(CLOCK_MONOTONIC_RAW, &ts)/ kNSperMS);
#else 
  return Some(clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW) / kNSperMS);
#endif
}  

mozglue/misc/AwakeTimeStamp.cpp:115:

AwakeTimeStamp AwakeTimeStamp::Now() {
#if !defined(MAC_OS_VERSION_10_12) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_10_12
    struct timespec tv;
    return AwakeTimeStamp(clock_gettime_missing(CLOCK_UPTIME_RAW, &tv)/ kNSperUS);
#else
    return AwakeTimeStamp(clock_gettime_nsec_np(CLOCK_UPTIME_RAW) / kNSperUS);
#endif 
} 
AwakeTimeStamp AwakeTimeStamp::NowLoRes() { return Now(); }

The reference to clock_gettime_nsec_np must come from the Rust file which has what seems to be a runtime detection of its availability. The two C++ files should build in a call to replacement functionality.

@RJVB
Copy link
Author

RJVB commented Oct 30, 2024

Hoping the attached patch will help speed up fixing this issue!

@RJVB
Copy link
Author

RJVB commented Nov 4, 2024 via email

@Wowfunhappy
Copy link

How about you write a dynasty-updating prefpane (I presume there's no updating functionality in FF Dynasty anyways)? ;)

I am planning on it, but it might take a while. I want to start on a stronger foundation this time so the codebase doesn't get out of control. I also have quite a few tweaks I want to apply on top, such as this code for fixing key equivalents. I'm working on extending that to add additional items to the menu such as "reload page", and then I want to make use of Firefox's theming support to make this look like a proper Aqua app.

@RJVB
Copy link
Author

RJVB commented Nov 4, 2024 via email

@Wowfunhappy
Copy link

Oops, I want to make Firefox look like a proper Aqua app. The toolbar should have the correct gradient and so on.

@RJVB
Copy link
Author

RJVB commented Nov 4, 2024 via email

@krackers
Copy link

krackers commented Nov 5, 2024

Firefox look like a proper Aqua app. The toolbar should have the correct gradient and so on.

Back in the FF78 days I had a theme which does this. I can share with you, don't know how much of FF has changed since then. Developing firefox themes is a pain. Everything about firefox is jank, I can't believe this is supposed to be the browser by and for developers. You can't even have an unpacked extension loaded for more than 24 hrs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants