NetBSD Problem Report #51966

From www@NetBSD.org  Sun Feb 12 20:38:44 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 351C77A26C
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 12 Feb 2017 20:38:44 +0000 (UTC)
Message-Id: <20170212203842.C44E37A296@mollari.NetBSD.org>
Date: Sun, 12 Feb 2017 20:38:42 +0000 (UTC)
From: roy@roypittman.com
Reply-To: roy@roypittman.com
To: gnats-bugs@NetBSD.org
Subject: firefox crashes frequently
X-Send-Pr-Version: www-1.0

>Number:         51966
>Category:       pkg
>Synopsis:       firefox crashes frequently
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    ryoon
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 12 20:40:00 +0000 2017
>Closed-Date:    Wed Feb 21 08:58:21 +0000 2018
>Last-Modified:  Wed Feb 21 08:58:21 +0000 2018
>Originator:     Roy Pittman
>Release:        NetBSD/amd64-7.0_STABLE, pkgsrc-2016Q4
>Organization:
>Environment:
NetBSD ratliff 7.0_STABLE NetBSD 7.0_STABLE (RATLIFF) #13: Sun Dec 25 16:29:39 MST 2016  roy@ratliff:/d0/build/netbsd-7/obj/amd64/sys/arch/amd64/compile/RATLIFF amd64
>Description:
Two days ago I removed firefox and reinstalled it. This was done with my /etc/mk.conf file which includes these lines:
PKG_DEFAULT_OPTIONS+=pam ssl -cups -pulseaudio -alsa
PKG_OPTIONS.firefox+=oss  debug
.if "${PKGPATH}" == "www/firefox"
  CFLAGS+=      -ggdb
  CXXFLAGS+=    -ggdb
  INSTALL_UNSTRIPPED=   yes
.endif

I rebuilt my OS yesterday with "MKDEBUG=yes" and "MKDEBUG_LIB=yes" and
installed the resulting "debug.tgz" and "xdebug.tgz" sets.

I then started firefox 50.1.0 in a terminal emulator.  Here is the output:
[10340] WARNING: Retargeting delivery to same thread: file /d0/build/pkgsrc/www/firefox/work/firefox-50.1.0/netwerk/protocol/http/nsHttpChannel.cpp, line 6749
Assertion failure: mSearchesOngoing > 0 && mSearches.Contains(aSearch), at /d0/build/pkgsrc/www/firefox/work/firefox-50.1.0/toolkit/components/autocomplete/nsAutoCompleteController.cpp:818
#01: XRE_TelemetryAccumulate[/usr/pkg/lib/firefox/libxul.so +0x38b040c]
#02: XRE_TelemetryAccumulate[/usr/pkg/lib/firefox/libxul.so +0x38b8bdf]
#03: NS_InvokeByIndex[/usr/pkg/lib/firefox/libxul.so +0xbfa325]
#04: std::pair<unsigned long const, float>::pair<unsigned long const&, 0ul>(std::tuple<unsigned long const&>&, std::tuple<>&, std::_Index_tuple<0ul>, std::_Index_tuple<>)[/usr/pkg/lib/firefox/libxul.so +0x477e42f]
#05: std::pair<unsigned long const, float>::pair<unsigned long const&, 0ul>(std::tuple<unsigned long const&>&, std::tuple<>&, std::_Index_tuple<0ul>, std::_Index_tuple<>)[/usr/pkg/lib/firefox/libxul.so +0x477c0b8]
#06: XRE_XPCShellMain[/usr/pkg/lib/firefox/libxul.so +0x1599e4d]
#07: XRE_XPCShellMain[/usr/pkg/lib/firefox/libxul.so +0x15a2679]
#08: std::__atomic_base<PRLock*>::store(PRLock*, std::memory_order)[/usr/pkg/lib/firefox/libxul.so +0x5b4a926]
#09: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc2e1b]
#10: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc3138]
#11: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc3162]
#12: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dd040e]
#13: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc2aa3]
#14: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc2ee4]
#15: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc3138]
#16: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc31c9]
#17: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3ca5feb]
#18: std::__atomic_base<PRLock*>::store(PRLock*, std::memory_order)[/usr/pkg/lib/firefox/libxul.so +0x5b4a926]
#19: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc2e1b]
#20: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc3138]
#21: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc31c9]
#22: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3d67579]
#23: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3d289e9]
#24: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3d2cead]
#25: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3d2e149]
#26: std::__atomic_base<PRLock*>::store(PRLock*, std::memory_order)[/usr/pkg/lib/firefox/libxul.so +0x5b4a926]
#27: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc2d1f]
#28: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc3138]
#29: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3dc3162]
#30: mozilla::scache::PathifyURI(nsIURI*, nsACString_internal&)[/usr/pkg/lib/firefox/libxul.so +0x3a883dd]
#31: ??? (???:???)
Memory fault (core dumped) 
1044 [roy@ratliff:/d2/home/roy]$ date
Sun Feb 12 06:10:11 MST 2017
1045 [roy@ratliff:/d2/home/roy]$ gdb firefox firefox.core
<snip>
[New process 2]
Core was generated by `firefox'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f7ff690e6fa in ?? ()
(gdb) bt
#0  0x00007f7ff690e6fa in ?? ()
#1  0x00007f7ff0cfd23b in ?? ()
#2  0x00007f7fffff7088 in ?? ()
#3  0x00007f7fffff7170 in ?? ()
#4  0x00007f7fffff70f0 in ?? ()
#5  0x0000000bffffa028 in ?? ()
#6  0x0000000000000400 in ?? ()
#7  0x0000000000000000 in ?? ()
(gdb) quit
1046 [roy@ratliff:/d2/home/roy]$ 

=====gdb bt from a previous crash 2017 02 10====

Core was generated by `firefox'.
> Program terminated with signal SIGSEGV, Segmentation fault.
> #0  0x00007f7ff690e6fa in ?? ()
> (gdb) bt
> #0  0x00007f7ff690e6fa in ?? ()
> #1  0x00007f7ff0cfd23b in ?? ()
> #2  0x00007f7fa54fe0f8 in ?? ()
> #3  0x00007f7fa54fe1e0 in ?? ()
> #4  0x00007f7fa54fe160 in ?? ()
> #5  0x0000000ba54fffc8 in ?? ()
> #6  0x0000000000000400 in ?? ()
> #7  0x0000000000000000 in ?? ()
> (gdb)

====I have other backtraces that are identical.=====

>How-To-Repeat:
When I leave firefox 50.1 running, started either from a terminal or from the gui, the crash will eventually recur.
It seems to happen more often when I have several firefox windows open. Sorry I can't be more specific.
>Fix:
Not known to me.

>Release-Note:

>Audit-Trail:
From: aran@100acres.us
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/51966
Date: Fri, 23 Jun 2017 14:33:02 -0700 (PDT)

 ----Next_Part(Fri_Jun_23_14_33_02_2017_562)--
 Content-Type: Text/Plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit

 The problem if Firefox's CrossProcessSemaphore.  On Linux, sem_t is a opaque
 structure.  On NetBSD, it is opaque pointer.  The sem_t is shared between two
 processes.  This, of course, does not work on NetBSD.

 I change the class mozilla::CrossProcessSemaphore to use pthread primitives to
 implement semaphore logic.  This works on my system:

 $uname -a
 NetBSD owl 8.99.1 NetBSD 8.99.1 (GENERIC) #2: Mon Jun 19 21:52:11 PDT 2017  aran@owl:/home/NetBSD/build/sys/arch/amd64/compile/GENERIC amd64

 Aran

 ----Next_Part(Fri_Jun_23_14_33_02_2017_562)--
 Content-Type: Text/Plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="patch-ipc_glue_CrossProcessSemaphore.h"

 $NetBSD$

 --- ipc/glue/CrossProcessSemaphore.h.orig	2017-06-05 20:45:20.000000000 +0000
 +++ ipc/glue/CrossProcessSemaphore.h
 @@ -91,7 +91,9 @@ private:
    HANDLE mSemaphore;
  #elif !defined(OS_MACOSX)
    RefPtr<mozilla::ipc::SharedMemoryBasic> mSharedBuffer;
 -  sem_t* mSemaphore;
 +  pthread_mutex_t*          mMutex;
 +  pthread_cond_t*           mNotZero;
 +  uint32_t*                 mValue;
    mozilla::Atomic<int32_t>* mRefCount;
  #endif
  };

 ----Next_Part(Fri_Jun_23_14_33_02_2017_562)--
 Content-Type: Text/Plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="patch-ipc_glue_CrossProcessSemaphore__posix.cpp"

 $NetBSD$

 --- ipc/glue/CrossProcessSemaphore_posix.cpp.orig	2017-06-05 20:45:20.000000000 +0000
 +++ ipc/glue/CrossProcessSemaphore_posix.cpp
 @@ -9,15 +9,20 @@
  #include "nsDebug.h"
  #include "nsISupportsImpl.h"
  #include <errno.h>
 +#include <iostream>
 +#include <unistd.h>
 +#include <limits>

  static const uint64_t kNsPerMs = 1000000;
  static const uint64_t kNsPerSec = 1000000000;

  namespace {

 -
  struct SemaphoreData {
 -  sem_t mSemaphore;
 +  pthread_mutex_t mMutex;
 +  pthread_cond_t  mNotZero;
 +  uint32_t        mValue;  
 +  
    mozilla::Atomic<int32_t> mRefCount;
    uint32_t mInitialValue;
  };
 @@ -44,15 +49,21 @@ CrossProcessSemaphore::Create(const char
      return nullptr;
    }

 -  if (sem_init(&data->mSemaphore, 1, aInitialValue)) {
 +  data->mValue = aInitialValue;
 +  if (pthread_mutex_init(&data->mMutex, NULL) ||
 +      pthread_cond_init(&data->mNotZero, NULL) ) {
      return nullptr;
    }

    CrossProcessSemaphore* sem = new CrossProcessSemaphore;
    sem->mSharedBuffer = sharedBuffer;
 -  sem->mSemaphore = &data->mSemaphore;
 -  sem->mRefCount = &data->mRefCount;
 -  *sem->mRefCount = 1;
 +  sem->mMutex        = &data->mMutex;  
 +  sem->mNotZero      = &data->mNotZero;  
 +  sem->mValue        = &data->mValue;
 +  sem->mRefCount     = &data->mRefCount;
 +  *sem->mRefCount    = 1;
 +
 +//  aran_log(*sem->mSemaphore);

    data->mInitialValue = aInitialValue;

 @@ -77,16 +88,10 @@ CrossProcessSemaphore::Create(CrossProce
    }

    SemaphoreData* data = static_cast<SemaphoreData*>(sharedBuffer->memory());
 -
 -  if (!data) {
 -    return nullptr;
 -  }
 -
 -  int32_t oldCount = data->mRefCount++;
 +  int oldCount = data->mRefCount++;
    if (oldCount == 0) {
 -    // The other side has already let go of their CrossProcessSemaphore, so now
 -    // mSemaphore is garbage. We need to re-initialize it.
 -    if (sem_init(&data->mSemaphore, 1, data->mInitialValue)) {
 +    if (pthread_mutex_init(&data->mMutex, NULL) ||
 +        pthread_cond_init(&data->mNotZero, NULL) ) {
        data->mRefCount--;
        return nullptr;
      }
 @@ -94,14 +99,18 @@ CrossProcessSemaphore::Create(CrossProce

    CrossProcessSemaphore* sem = new CrossProcessSemaphore;
    sem->mSharedBuffer = sharedBuffer;
 -  sem->mSemaphore = &data->mSemaphore;
 +  sem->mMutex        = &data->mMutex;  
 +  sem->mNotZero      = &data->mNotZero;  
 +  sem->mValue        = &data->mValue;
    sem->mRefCount = &data->mRefCount;
    return sem;
  }


  CrossProcessSemaphore::CrossProcessSemaphore()
 -  : mSemaphore(nullptr)
 +  : mMutex (nullptr)
 +  , mNotZero (nullptr)
 +  , mValue (nullptr)
    , mRefCount(nullptr)
  {
    MOZ_COUNT_CTOR(CrossProcessSemaphore);
 @@ -113,35 +122,54 @@ CrossProcessSemaphore::~CrossProcessSema

    if (oldCount == 0) {
      // Nothing can be done if the destroy fails so ignore return code.
 -    Unused << sem_destroy(mSemaphore);
 +    (void)pthread_cond_destroy(mNotZero);
 +    (void)pthread_mutex_destroy(mMutex);
    }

    MOZ_COUNT_DTOR(CrossProcessSemaphore);
  }

 +static struct timespec
 +makeAbsTime(const Maybe<TimeDuration>& aWaitTime) {
 +  struct timespec ts;
 +  if (aWaitTime.isSome()) {
 +    clock_gettime(CLOCK_REALTIME, &ts);
 +    ts.tv_nsec += (kNsPerMs * aWaitTime->ToMilliseconds());
 +    ts.tv_sec += ts.tv_nsec / kNsPerSec;
 +    ts.tv_nsec %= kNsPerSec;
 +  }
 +  else {
 +    ts.tv_sec = std::numeric_limits<time_t>::max();
 +    ts.tv_nsec = 0;
 +  }
 +  return ts;
 +}
 +
  bool
  CrossProcessSemaphore::Wait(const Maybe<TimeDuration>& aWaitTime)
  {
    MOZ_ASSERT(*mRefCount > 0, "Attempting to wait on a semaphore with zero ref count");
    int ret;
 -  if (aWaitTime.isSome()) {
 -    struct timespec ts;
 -    if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
 -      return false;
 -    }
 -
 -    ts.tv_nsec += (kNsPerMs * aWaitTime->ToMilliseconds());
 -    ts.tv_sec += ts.tv_nsec / kNsPerSec;
 -    ts.tv_nsec %= kNsPerSec;
 +  struct timespec ts = makeAbsTime(aWaitTime);

 -    while ((ret = sem_timedwait(mSemaphore, &ts)) == -1 && errno == EINTR) {
 -      continue;
 +  ret = pthread_mutex_timedlock(mMutex, &ts);
 +  while (ret == -1 && errno == EINTR) {
 +    ret = pthread_mutex_timedlock(mMutex, &ts);
 +  }
 +  
 +  if(ret == 0) {
 +    while(ret == 0 && mValue == 0) {
 +      ret = pthread_cond_timedwait(mNotZero, mMutex, &ts);
 +      while(ret == -1 && errno == EINTR) {
 +        ret = pthread_cond_timedwait(mNotZero, mMutex, &ts);
 +      }
      }
 -  } else {
 -    while ((ret = sem_wait(mSemaphore)) == -1 && errno == EINTR) {
 -      continue;
 +    if(ret == 0) {
 +      --(*mValue);
      }
 +    pthread_mutex_unlock(mMutex);
    }
 +  
    return ret == 0;
  }

 @@ -149,7 +177,16 @@ void
  CrossProcessSemaphore::Signal()
  {
    MOZ_ASSERT(*mRefCount > 0, "Attempting to signal a semaphore with zero ref count");
 -  sem_post(mSemaphore);
 +  int ret;
 +  ret = pthread_mutex_lock(mMutex);
 +  while(ret == -1 && errno == EINTR) {
 +    ret = pthread_mutex_lock(mMutex);
 +  }
 +  if(ret == 0) {
 +    ++(*mValue);
 +    pthread_cond_signal(mNotZero);
 +    pthread_mutex_unlock(mMutex);
 +  }
  }

  CrossProcessSemaphoreHandle
 @@ -160,7 +197,6 @@ CrossProcessSemaphore::ShareToProcess(ba
    if (mSharedBuffer && !mSharedBuffer->ShareToProcess(aTargetPid, &result)) {
      MOZ_CRASH();
    }
 -
    return result;
  }


 ----Next_Part(Fri_Jun_23_14_33_02_2017_562)----

Responsible-Changed-From-To: pkg-manager->ryoon
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Fri, 23 Jun 2017 22:23:41 +0000
Responsible-Changed-Why:
Over to maintainer
(includes patch!)


From: Kamil Rytarowski <n54@gmx.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/51966 (firefox crashes frequently)
Date: Sun, 25 Jun 2017 04:35:19 +0200

 This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
 --3LtL0H8phubD4b88cHiXOrgpqDXPQQl3j
 Content-Type: multipart/mixed; boundary="DA992h1DiUGK1xW6cpNMUmuIFt66dQMOj";
  protected-headers="v1"
 From: Kamil Rytarowski <n54@gmx.com>
 To: gnats-bugs@NetBSD.org
 Message-ID: <90c85181-3cb1-e39e-1d26-f2c48e634539@gmx.com>
 Subject: Re: pkg/51966 (firefox crashes frequently)
 References: <pr-pkg-51966@gnats.netbsd.org>
  <20170212203842.C44E37A296@mollari.NetBSD.org>
  <20170623222342.1AE4E7A2A5@mollari.NetBSD.org>
 In-Reply-To: <20170623222342.1AE4E7A2A5@mollari.NetBSD.org>

 --DA992h1DiUGK1xW6cpNMUmuIFt66dQMOj
 Content-Type: text/plain; charset=utf-8
 Content-Language: en-US
 Content-Transfer-Encoding: quoted-printable

 On 24.06.2017 00:23, wiz@NetBSD.org wrote:
 > Synopsis: firefox crashes frequently
 >=20
 > Responsible-Changed-From-To: pkg-manager->ryoon
 > Responsible-Changed-By: wiz@NetBSD.org
 > Responsible-Changed-When: Fri, 23 Jun 2017 22:23:41 +0000
 > Responsible-Changed-Why:
 > Over to maintainer
 > (includes patch!)
 >=20
 >=20
 >=20

 This bug is still valid on:

 NetBSD chieftec 8.99.1 NetBSD 8.99.1 (GENERIC) #2: Sat Jun 24 11:15:28
 CEST 2017
 root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC amd64

 With pkgsrc-current. I'm reproducing it with www/firefox and
 www/firefox45. I have not tested older ones... but I might need to get th=
 em.

 I tried to apply this patch but it seems incomplete, it doesn't build
 for me.


 --DA992h1DiUGK1xW6cpNMUmuIFt66dQMOj--

 --3LtL0H8phubD4b88cHiXOrgpqDXPQQl3j
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: OpenPGP digital signature
 Content-Disposition: attachment; filename="signature.asc"

 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2

 iQIcBAEBCAAGBQJZTyFuAAoJEEuzCOmwLnZsCz4P/RVZONTK87gsbUOIMDGtTBw2
 2wlqraXueo2t+uD6UiiS3M8MU4jGyhGl89TtX2ZSngvBzscMhzQBvyfCr3kzjcFY
 gIxeHtC+jKfQXfS62t/oxJooqzjW0vaf1y8rHgd+dySsjK9HPOmyTdwlaQcCYzPs
 hLi5FEAuCgBaUwGX4jC7Zr5ziGZ1dkraMf3uF+bokL/r/L1kVUcErUfww5Bvkqzs
 q10V2Apjf3Ek26wB9ebUMdUhupKK5JabjxucJOEgNrPHWfD4bc1hn1qXhqUgDTVl
 LpVyVySnTfQp/ZaYTvuZRWRVLlz5bxZepxt9BnB8nxFJpxlWmCU2JW5SvzF9z7iK
 UiSXiM/Apt+7pbZ3x9A2WNxmZoZzvK749yjtpk21N3HZ97/G7ylHrlNQbc+rojaX
 iWtdUA4bV80z2Slm6JI0d8g9Fs9IUL5elnrlxFcf9BYVrOzppb2/wt1B+xqgcCQb
 ZOvXp9SzNfdC4Y6U1N9q5MorpgboO1O7dniD0+QZldQAnSbGUb30nslQg7woxOO9
 4fzesYceUbTSX5YXDS0BnR//cn6uJxTERoYMCNDlF4QGTOQatpGOP5kyT+8zLZXQ
 wWWyC8USf/2uEy+5WQDGKRZmdsqluphIKDJOz0pyB+fSBvTJ18lAVuRgluX9unZa
 YGJrb0FVj7fz8eiqyAsK
 =fE2O
 -----END PGP SIGNATURE-----

 --3LtL0H8phubD4b88cHiXOrgpqDXPQQl3j--

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: ryoon@NetBSD.org, aran@100acres.us, tsutsui@ceres.dti.ne.jp
Subject: Re: pkg/51966
Date: Sun, 25 Jun 2017 15:20:39 +0900

 Hi,

 I've revised Aran's patch to:
  - move changes (avoid use of sem_t) inside #if defined(__NetBSD__)
  - avoid use of pthread_mutex_timedlock(3) (not available on NetBSD 7.1)
   -> I'm not sure if pthread_mutex_lock(3) is acceptable in this case though

 It seems working on NetBSD/i386 7.1 with browser.tabs.remote.autostart.2=true
 (i.e. e10s enabled).

 Note for NetBSD 7.1 PR pkg/52309 (avoid PTHREAD_PRIO_INHERIT, which
 is not available on 7.1 either) is also necessary.

 --- shar from here ---

 # This is a shell archive.  Save it in a file, remove anything before
 # this line, and then unpack it by entering "sh file".  Note, it may
 # create directories; files and directories will be owned by you and
 # have default permissions.
 #
 # This archive contains:
 #
 #	patches/patch-ipc_glue_CrossProcessSemaphore.h
 #	patches/patch-ipc_glue_CrossProcessSemaphore__posix.cpp
 #
 echo x - patches/patch-ipc_glue_CrossProcessSemaphore.h
 sed 's/^X//' >patches/patch-ipc_glue_CrossProcessSemaphore.h << 'END-of-patches/patch-ipc_glue_CrossProcessSemaphore.h'
 X$NetBSD$
 X
 X- avoid use of sem_t on NetBSD
 X  http://mail-index.netbsd.org/pkgsrc-bugs/2017/06/23/msg062225.html
 X
 X--- ipc/glue/CrossProcessSemaphore.h.orig	2017-06-05 20:45:20.000000000 +0000
 X+++ ipc/glue/CrossProcessSemaphore.h
 X@@ -91,7 +91,13 @@ private:
 X   HANDLE mSemaphore;
 X #elif !defined(OS_MACOSX)
 X   RefPtr<mozilla::ipc::SharedMemoryBasic> mSharedBuffer;
 X+#if defined(__NetBSD__)
 X+  pthread_mutex_t* mMutex;
 X+  pthread_cond_t* mNotZero;
 X+  uint32_t* mValue;
 X+#else
 X   sem_t* mSemaphore;
 X+#endif
 X   mozilla::Atomic<int32_t>* mRefCount;
 X #endif
 X };
 END-of-patches/patch-ipc_glue_CrossProcessSemaphore.h
 echo x - patches/patch-ipc_glue_CrossProcessSemaphore__posix.cpp
 sed 's/^X//' >patches/patch-ipc_glue_CrossProcessSemaphore__posix.cpp << 'END-of-patches/patch-ipc_glue_CrossProcessSemaphore__posix.cpp'
 X$NetBSD$
 X
 X- avoid use of sem_t on NetBSD
 X  http://mail-index.netbsd.org/pkgsrc-bugs/2017/06/23/msg062225.html
 X
 X--- ipc/glue/CrossProcessSemaphore_posix.cpp.orig	2017-06-25 05:29:49.000000000 +0000
 X+++ ipc/glue/CrossProcessSemaphore_posix.cpp
 X@@ -9,6 +9,11 @@
 X #include "nsDebug.h"
 X #include "nsISupportsImpl.h"
 X #include <errno.h>
 X+#if defined(__NetBSD__)
 X+#include <iostream>
 X+#include <unistd.h>
 X+#include <limits>
 X+#endif
 X 
 X static const uint64_t kNsPerMs = 1000000;
 X static const uint64_t kNsPerSec = 1000000000;
 X@@ -17,7 +22,13 @@ namespace {
 X 
 X 
 X struct SemaphoreData {
 X+#if defined(__NetBSD__)
 X+  pthread_mutex_t mMutex;
 X+  pthread_cond_t mNotZero;
 X+  uint32_t mValue;
 X+#else
 X   sem_t mSemaphore;
 X+#endif
 X   mozilla::Atomic<int32_t> mRefCount;
 X   uint32_t mInitialValue;
 X };
 X@@ -44,13 +55,27 @@ CrossProcessSemaphore::Create(const char
 X     return nullptr;
 X   }
 X 
 X+#if defined(__NetBSD__)
 X+  data->mValue = aInitialValue;
 X+  if (pthread_mutex_init(&data->mMutex, NULL) ||
 X+      pthread_cond_init(&data->mNotZero, NULL) ) {
 X+    return nullptr;
 X+  }
 X+#else
 X   if (sem_init(&data->mSemaphore, 1, aInitialValue)) {
 X     return nullptr;
 X   }
 X+#endif
 X 
 X   CrossProcessSemaphore* sem = new CrossProcessSemaphore;
 X   sem->mSharedBuffer = sharedBuffer;
 X+#if defined(__NetBSD__)
 X+  sem->mMutex = &data->mMutex;  
 X+  sem->mNotZero = &data->mNotZero;  
 X+  sem->mValue = &data->mValue;
 X+#else
 X   sem->mSemaphore = &data->mSemaphore;
 X+#endif
 X   sem->mRefCount = &data->mRefCount;
 X   *sem->mRefCount = 1;
 X 
 X@@ -84,24 +109,44 @@ CrossProcessSemaphore::Create(CrossProce
 X 
 X   int32_t oldCount = data->mRefCount++;
 X   if (oldCount == 0) {
 X+#if defined(__NetBSD__)
 X+    if (pthread_mutex_init(&data->mMutex, NULL) ||
 X+        pthread_cond_init(&data->mNotZero, NULL) ) {
 X+      data->mRefCount--;
 X+      return nullptr;
 X+    }
 X+#else
 X     // The other side has already let go of their CrossProcessSemaphore, so now
 X     // mSemaphore is garbage. We need to re-initialize it.
 X     if (sem_init(&data->mSemaphore, 1, data->mInitialValue)) {
 X       data->mRefCount--;
 X       return nullptr;
 X     }
 X+#endif
 X   }
 X 
 X   CrossProcessSemaphore* sem = new CrossProcessSemaphore;
 X   sem->mSharedBuffer = sharedBuffer;
 X+#if defined(__NetBSD__)
 X+  sem->mMutex = &data->mMutex;  
 X+  sem->mNotZero = &data->mNotZero;  
 X+  sem->mValue = &data->mValue;
 X+#else
 X   sem->mSemaphore = &data->mSemaphore;
 X+#endif
 X   sem->mRefCount = &data->mRefCount;
 X   return sem;
 X }
 X 
 X 
 X CrossProcessSemaphore::CrossProcessSemaphore()
 X+#if defined(__NetBSD__)
 X+  : mMutex (nullptr)
 X+  , mNotZero (nullptr)
 X+  , mValue (nullptr)
 X+#else
 X   : mSemaphore(nullptr)
 X+#endif
 X   , mRefCount(nullptr)
 X {
 X   MOZ_COUNT_CTOR(CrossProcessSemaphore);
 X@@ -113,17 +158,58 @@ CrossProcessSemaphore::~CrossProcessSema
 X 
 X   if (oldCount == 0) {
 X     // Nothing can be done if the destroy fails so ignore return code.
 X+#if defined(__NetBSD__)
 X+    (void)pthread_cond_destroy(mNotZero);
 X+    (void)pthread_mutex_destroy(mMutex);
 X+#else
 X     Unused << sem_destroy(mSemaphore);
 X+#endif
 X   }
 X 
 X   MOZ_COUNT_DTOR(CrossProcessSemaphore);
 X }
 X 
 X+#if defined(__NetBSD__)
 X+static struct timespec
 X+makeAbsTime(const Maybe<TimeDuration>& aWaitTime) {
 X+  struct timespec ts;
 X+  if (aWaitTime.isSome()) {
 X+    clock_gettime(CLOCK_REALTIME, &ts);
 X+    ts.tv_nsec += (kNsPerMs * aWaitTime->ToMilliseconds());
 X+    ts.tv_sec += ts.tv_nsec / kNsPerSec;
 X+    ts.tv_nsec %= kNsPerSec;
 X+  }
 X+  else {
 X+    ts.tv_sec = std::numeric_limits<time_t>::max();
 X+    ts.tv_nsec = 0;
 X+  }
 X+  return ts;
 X+}
 X+#endif
 X+
 X bool
 X CrossProcessSemaphore::Wait(const Maybe<TimeDuration>& aWaitTime)
 X {
 X   MOZ_ASSERT(*mRefCount > 0, "Attempting to wait on a semaphore with zero ref count");
 X   int ret;
 X+#if defined(__NetBSD__)
 X+  struct timespec ts = makeAbsTime(aWaitTime);
 X+
 X+  ret = pthread_mutex_lock(mMutex);
 X+
 X+  if (ret == 0) {
 X+    while (ret == 0 && mValue == 0) {
 X+      ret = pthread_cond_timedwait(mNotZero, mMutex, &ts);
 X+      while (ret == -1 && errno == EINTR) {
 X+        ret = pthread_cond_timedwait(mNotZero, mMutex, &ts);
 X+      }
 X+    }
 X+    if (ret == 0) {
 X+      --(*mValue);
 X+    }
 X+    pthread_mutex_unlock(mMutex);
 X+  }
 X+#else
 X   if (aWaitTime.isSome()) {
 X     struct timespec ts;
 X     if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
 X@@ -142,6 +228,7 @@ CrossProcessSemaphore::Wait(const Maybe<
 X       continue;
 X     }
 X   }
 X+#endif
 X   return ret == 0;
 X }
 X 
 X@@ -149,7 +236,17 @@ void
 X CrossProcessSemaphore::Signal()
 X {
 X   MOZ_ASSERT(*mRefCount > 0, "Attempting to signal a semaphore with zero ref count");
 X+#if defined(__NetBSD__)
 X+  int ret;
 X+  ret = pthread_mutex_lock(mMutex);
 X+  if (ret == 0) {
 X+    ++(*mValue);
 X+    pthread_cond_signal(mNotZero);
 X+    pthread_mutex_unlock(mMutex);
 X+  }
 X+#else
 X   sem_post(mSemaphore);
 X+#endif
 X }
 X 
 X CrossProcessSemaphoreHandle
 END-of-patches/patch-ipc_glue_CrossProcessSemaphore__posix.cpp
 exit


 ---
 Izumi Tsutsui

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51966 CVS commit: pkgsrc/www/firefox
Date: Thu, 29 Jun 2017 08:07:59 +0000

 Module Name:	pkgsrc
 Committed By:	martin
 Date:		Thu Jun 29 08:07:59 UTC 2017

 Modified Files:
 	pkgsrc/www/firefox: Makefile distinfo
 Added Files:
 	pkgsrc/www/firefox/patches: patch-ipc_glue_CrossProcessSemaphore.h
 	    patch-ipc_glue_CrossProcessSemaphore__posix.cpp

 Log Message:
 Add patch from PR 51966.


 To generate a diff of this commit:
 cvs rdiff -u -r1.297 -r1.298 pkgsrc/www/firefox/Makefile
 cvs rdiff -u -r1.282 -r1.283 pkgsrc/www/firefox/distinfo
 cvs rdiff -u -r0 -r1.1 \
     pkgsrc/www/firefox/patches/patch-ipc_glue_CrossProcessSemaphore.h \
     pkgsrc/www/firefox/patches/patch-ipc_glue_CrossProcessSemaphore__posix.cpp

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Tue, 20 Feb 2018 05:55:13 +0000
State-Changed-Why:
the patch was committed 8 months ago, is it working?


From: roy@betweentheleaves.com
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/51966 (firefox crashes frequently)
Date: Tue, 20 Feb 2018 05:58:35 -0700

 On 2018-02-19 22:55, dholland@NetBSD.org wrote:
 > Synopsis: firefox crashes frequently
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: dholland@NetBSD.org
 > State-Changed-When: Tue, 20 Feb 2018 05:55:13 +0000
 > State-Changed-Why:
 > the patch was committed 8 months ago, is it working?

 Yes, much better.  Thank you.

State-Changed-From-To: feedback->closed
State-Changed-By: bsiegert@NetBSD.org
State-Changed-When: Wed, 21 Feb 2018 08:58:21 +0000
State-Changed-Why:
working better now


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.