Odd problem, multithread issue? Topic is solved

Support and discussions for the x86/x64 Linux version of Pale Moon.

Moderators: trava90, satrow

Angii
Newbie
Newbie
Posts: 5
Joined: Wed, 02 May 2018, 01:07

Odd problem, multithread issue?

Postby Angii » Wed, 02 May 2018, 01:16

I've been just dealing with this problem for a while, but recently it happened to me abruptly immediately after reopening Pale Moon. I have a feeling that it may be something else in my setup causing this, but it only seems to have happened to pale moon the past few months, so I figured I should finally post about it. Every once in a while, Pale Moon will abruptly close itself. I started running it via a terminal so I could see what causes it, and every time it abruptly closes, it outputs:

Code: Select all

[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
palemoon: xcb_io.c:259: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Aborted

I did a small amount of digging, and I haven't seen anyone else having this issue (let alone for the past monthish or so like I have), but I'm not sure what could be causing this to specifically affect Pale Moon, let alone Pale Moon across many versions. The builds this has been happening on are the ones installed via the official tool (pm-installer.sh) and not ones that I've compiled or anything. If anyone might have any insight, I thank you in advance; this has begun to confuse me a fair bit.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 20996
Joined: Sun, 28 Aug 2011, 17:27
Location: 58.5°N 15.5°E
Contact:

Re: Odd problem, multithread issue?

Postby Moonchild » Wed, 02 May 2018, 09:50

From what little I know (and I may be wrong) using xcb instead of xlib might not work very well; our cairo lib only has experimental support for xcb.
Not that I'd have any idea how to help you configure your X server to use something else though, but that seems to be a clue. Other people more familiar with X should chime in.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

Walter Dnes
Lunatic
Lunatic
Posts: 474
Joined: Thu, 30 Jul 2015, 20:29
Location: Vaughan, ON, Canada

Re: Odd problem, multithread issue?

Postby Walter Dnes » Wed, 02 May 2018, 21:22

Angii wrote:The builds this has been happening on are the ones installed via the official tool (pm-installer.sh) and not ones that I've compiled or anything.

Your personal builds are not crashing, while the official build is; correct? Maybe we can narrow things down by looking at the differences in the builds, to see what's causing the different behaviour. Which compiler are you using, and can you post your mozconfig? What distro (32/64 bits) are you using?
There's a right way
There's a wrong way
And then there's my way

Angii
Newbie
Newbie
Posts: 5
Joined: Wed, 02 May 2018, 01:07

Re: Odd problem, multithread issue?

Postby Angii » Thu, 03 May 2018, 00:59

Moonchild wrote: [...] our cairo lib only has experimental support for xcb. [...]


That could be it, I genuinely am not particularly knowledgeable about Xlib and xcb, so I suppose anything is possible here; I thought applications could choose which they wanted to use when both are present, but I could be mistaken for sure.

Walter Dnes wrote:Your personal builds are not crashing, while the official build is; correct?[...] What distro (32/64 bits) are you using?


Ah, sorry for the misunderstanding, I was just saying that they were official builds so nobody thought it was just my own builds messing up; I have not tried compiling Pale Moon myself to see if that corrects the issue. Mozconfig is used in building Pale Moon/Firefox, right? I don't think I have one, as such. The distro I'm using is Void Linux (64bit), though; it's possible it's a distro issue, but I haven't seen any xcb errors on the distro's forums (first place I looked to, figuring it was a bad lib update or something). This genuinely does not generally happen that often, maybe every couple of days (sometimes not for a week+) of Pale Moon being open (but then sometimes multiple times in a row quickly upon reopening PM), dmesg never has anything to say during these times, either. I'm not sure where else I would look for relevant log information regarding the issue.

Angii
Newbie
Newbie
Posts: 5
Joined: Wed, 02 May 2018, 01:07

Re: Odd problem, multithread issue?

Postby Angii » Sat, 05 May 2018, 21:39

A small secondary question (I'm not a fan of double posting, but I just noticed this today), I noticed Pale Moon has a launch option (--sync) which has as its description: "Make X calls synchronous." Is it possible that this would solve my problem as a band-aid, so to speak? I'm not exactly sure what is causing the xcb error, but it seems (to my untrained eye, I guess) to be things somehow being lost in a sequence, so perhaps this would solve it? I'm not aware what --sync does beyond it's description, so it's possible it's entirely unrelated, but, I thought it might be worth an ask.

EDIT: Can already confirm it doesn't help, had the same issue pop up while running PM with --sync just to see if it helped at all. Oh well, that was worth a shot at least.
Last edited by Angii on Sat, 05 May 2018, 23:05, edited 1 time in total.

vannilla
Moongazer
Moongazer
Posts: 11
Joined: Sat, 05 May 2018, 13:29

Re: Odd problem, multithread issue?

Postby vannilla » Sun, 06 May 2018, 12:07

XCB supports thread out of the box, so in a pure XCB setup there shouldn't be thread-related issues unless the programmer does some dark magic with the library (it is not 100% thread safe, even though normally there are no problems).

Threads are a problem with Xlib, and, in fact, what you see is an error from that library. It's prefixed with "[xcb]" because whoever is using XCB calls is configured to intercept events and errors generated by Xlib calls.
Since I don't know what uses XCB in Pale Moon, I can't think of any possible cause, but my guess is that there's something that normally would use XCB but for some actions require the use of Xlib, like OpenGL.

About the "--sync" flag, that has nothing to do with multithread, but with communication between the application (in this case Pale Moon) and the X server.
Most messages are asynchronous, as they send a request to the server which will apply them when the application says so (e.g. with XFlush).
Making them synchronous means that the server will apply the request as soon as it's received, which is the last thing you want (it makes things slower, and in some cases can actually cause problems).

I hope my explanation can help finding the issue (I never had this problem by the way).

dinosaur
Fanatic
Fanatic
Posts: 106
Joined: Tue, 03 Jun 2014, 09:26
Location: France

Re: Odd problem, multithread issue?  Topic is solved

Postby dinosaur » Sat, 12 May 2018, 12:10

To ensure Xlib (and all libraries consuming it) is properly initialized in thread-safe mode, you must make sure that XInitThreads() is called before any other call (direct or indirect) to Xlib.

In Pale Moon, this call appears in toolkit/xre/nsAppRunner.cpp (around line 3242 in current PM version), where you can see:

Code: Select all

#ifdef MOZ_X11
  // Init X11 in thread-safe mode. Must be called prior to the first call to XOpenDisplay
  // (called inside gdk_display_open). This is a requirement for off main tread compositing.
  // This is done only on X11 platforms if the environment variable MOZ_USE_OMTC is set so
  // as to avoid overhead when omtc is not used.
  //
  // On nightly builds, we call this by default to enable OMTC for Electrolysis testing. On
  // aurora, beta, and release builds, there is a small tpaint regression from enabling this
  // call, so it sits behind an environment variable.
  //
  // An environment variable is used instead of a pref on X11 platforms because we start having
  // access to prefs long after the first call to XOpenDisplay which is hard to change due to
  // interdependencies in the initialization.
# ifndef NIGHTLY_BUILD
  if (PR_GetEnv("MOZ_USE_OMTC") ||
      PR_GetEnv("MOZ_OMTC_ENABLED"))
# endif
  {
    XInitThreads();
  }
#endif

Obviously, if NIGHTLY_BUILD is undefined (or 0) and neither of MOZ_USE_OMTC or MOZ_OMTC_ENABLED environment variables are set, then XInitThreads() is *not* called.

I suggest systematically calling XInitThreads() instead (it won't hurt PM since Electrolysis is not used).

Note that some OpenGL drivers (e.g. NVIDIA's proprietary driver) will need Xlib to be initialized multi-threaded in order to be able to themselves use multi-threaded rendering.
Last edited by dinosaur on Sat, 12 May 2018, 12:21, edited 4 times in total.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 20996
Joined: Sun, 28 Aug 2011, 17:27
Location: 58.5°N 15.5°E
Contact:

Re: Odd problem, multithread issue?

Postby Moonchild » Sat, 12 May 2018, 12:30

@Dinosaur: If this was a systematic issue then Pale Moon would fail on ANY Linux/X11 system -- that's obviously not the case.
It would be interesting to know if setting MOZ_USE_OMTC solves the issue for the OP. If so, then for some reason they system assumes or uses xlib multithreaded even if consumers do not.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

dinosaur
Fanatic
Fanatic
Posts: 106
Joined: Tue, 03 Jun 2014, 09:26
Location: France

Re: Odd problem, multithread issue?

Postby dinosaur » Sat, 12 May 2018, 13:14

Moonchild wrote:@Dinosaur: If this was a systematic issue then Pale Moon would fail on ANY Linux/X11 system -- that's obviously not the case.

Not systematic, no... There are so many desktop environments, window managers, compositors, plus X11, (X)Wayland versions, display drivers, not to count the amount of Linux distros, each with their own versions of the various libraries...

Moonchild wrote:It would be interesting to know if setting MOZ_USE_OMTC solves the issue for the OP.

Yep, for a start...

Note that I am currently running a XInitThreads()-forced custom PM build, with no trouble whatsoever.

Angii
Newbie
Newbie
Posts: 5
Joined: Wed, 02 May 2018, 01:07

Re: Odd problem, multithread issue?

Postby Angii » Sun, 13 May 2018, 22:26

Thanks for looking into the problem, everyone! I've set the environment variable MOZ_OMTC_ENABLED=1 to see if this solves the problem; as the issue was rather sporadic (could go a week or more before having a sudden close) I won't know for sure if this has resolved the problem until nothing happens for a while, I suppose. I've stuck this into my /etc/environment as well to ensure I don't forget to set it whenever I restart my laptop. Again, thanks so much for the help, I know I never would've figured this out on my own, nor did I really know enough about Xlib/xcb to know where to start looking, either. If I don't have any sudden problems for a week or two I guess it's safe to assume setting the variable solved my problem and report back here. I'll swing back by if it doesn't solve my problem as well; although, if setting this environment variable ensures Pale Moon calls XInitThreads() I can't imagine it not solving my problem. Thanks again, everyone.

Angii
Newbie
Newbie
Posts: 5
Joined: Wed, 02 May 2018, 01:07

Re: Odd problem, multithread issue?

Postby Angii » Tue, 15 May 2018, 22:07

Weirdly enough, the sudden close just happened for me again. Same error as before was printed:

Code: Select all

[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.

I was sure to check my environment variables afterwards, and yes, MOZ_OMTC_ENABLED=1 is still present; I'm not quite sure what to make of this now. I suppose it may be an issue with the xlib or xcb libraries present in my distro, but PM is the only program which experiences this problem. I suppose my next step is to try a fresh profile just to ensure there isn't some odd lingering issue there. As I'm the only one with this problem, I think it's fairly clear isn't a defect in Pale Moon however, so I'll mark this as solved and try that. Thanks for all the help, everyone! If starting a fresh profile solves it I'll be sure to post a note about it later.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 20996
Joined: Sun, 28 Aug 2011, 17:27
Location: 58.5°N 15.5°E
Contact:

Re: Odd problem, multithread issue?

Postby Moonchild » Thu, 17 May 2018, 18:18

Well, it's clear then that not calling XinitThreads isn't the issue. So, it was a nice theory, but alas incorrect.
If this was the case I would have expected to have heard from this much much much sooner, anyway.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.


Return to “Pale Moon for Linux”

Who is online

Users browsing this forum: Linkdex [Bot] and 4 guests