Closed Bug 1720740 Opened 3 years ago Closed 3 years ago

nightly - XPCJSContext.cpp:94:25: error: constexpr variable 'kWatchdogStackSize' must be initialized by a constant expression

Categories

(Core :: XPConnect, defect)

Firefox 92
defect

Tracking

()

RESOLVED DUPLICATE of bug 1721326

People

(Reporter: mozilla, Unassigned)

References

(Regression)

Details

(Keywords: regression)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0

Steps to reproduce:

Update hg repository to the latest version.
run mach build

Actual results:

0:21.62 In file included from Unified_cpp_js_xpconnect_src0.cpp:74:
0:21.62 /mnt/to_archive/accum/src/firefox-source/js/xpconnect/src/XPCJSContext.cpp:94:25: error: constexpr variable 'kWatchdogStackSize' must be initialized by a constant expression
0:21.62 static constexpr size_t kWatchdogStackSize =
0:21.62 ^
0:21.62 /mnt/to_archive/accum/src/firefox-source/js/xpconnect/src/XPCJSContext.cpp:95:5: note: non-constexpr function '__sysconf' cannot be used in a constant expression
0:21.62 PTHREAD_STACK_MIN < 32 * 1024 ? 32 * 1024 : PTHREAD_STACK_MIN;
0:21.62 ^
0:21.62 /usr/include/bits/pthread_stack_min-dynamic.h:26:30: note: expanded from macro 'PTHREAD_STACK_MIN'
0:21.62 # define PTHREAD_STACK_MIN __sysconf (__SC_THREAD_STACK_MIN_VALUE)
0:21.62 ^
0:21.62 /usr/include/bits/pthread_stack_min-dynamic.h:24:17: note: declared here
0:21.62 extern long int __sysconf (int __name) __THROW;
0:21.62 ^
0:24.44 1 error generated.

Expected results:

nightly should have built

The Bugbug bot thinks this bug should belong to the 'Firefox Build System::General' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → General
Product: Firefox → Firefox Build System

Have you set up a mozconfig? I can't reproduce this failure locally on c75f4ae44937.

Flags: needinfo?(mozilla)

@2
As I answered in the other bug, https://bugzilla.mozilla.org/show_bug.cgi?id=1721251, I wasn't able to find a .mozconfig (or mozconfig) file in either ~ or the hg repository directory. Unfortunately, I can no longer reproduce this error here either, because it has been pre-empted by the error in https://bugzilla.mozilla.org/show_bug.cgi?id=1721251 .

Flags: needinfo?(mozilla)

OK, I think I've figured this out. The problem is a mismatch between the nightly code and the pthread macro.

This is the code in js/xpconnect/src/XPCJSContext.cpp

// The watchdog thread loop is pretty trivial, and should not require much stack
// space to do its job. So only give it 32KiB or the platform minimum.
#if !defined(PTHREAD_STACK_MIN)
#  define PTHREAD_STACK_MIN 0
#endif
static constexpr size_t kWatchdogStackSize =
    PTHREAD_STACK_MIN < 32 * 1024 ? 32 * 1024 : PTHREAD_STACK_MIN;

This is the pthread definition in /usr/include/bits/pthread_stack_min-dynamic.h, part of glibc, 
Name        : glibc-headers-x86
Version     : 2.33.9000
Release     : 43.fc35
Architecture: noarch

#ifndef PTHREAD_STACK_MIN
# if defined __USE_DYNAMIC_STACK_SIZE && __USE_DYNAMIC_STACK_SIZE
#  ifndef __ASSEMBLER__
#   define __SC_THREAD_STACK_MIN_VALUE 75
__BEGIN_DECLS
extern long int __sysconf (int __name) __THROW;
__END_DECLS
#   define PTHREAD_STACK_MIN __sysconf (__SC_THREAD_STACK_MIN_VALUE)
#  endif
# else
#  include <bits/pthread_stack_min.h>
# endif
#endif

The nightly code wants a constexpr, but the definition of __sysconf is extern long int

I think the latest glibc is incorporating pthread, and it will no longer be separate code, maybe this changed as part of that consolidation, thus the new error.

Solution? I don't know, my C++ fu is weak.

Nice, good eye 👍
Heads up that you can denote code blocks with triple-backticks like Markdown.
(I'll leave the solution consideration here to glandium).

Component: General → XPConnect
Product: Firefox Build System → Core
Regressed by: 1503968
Has Regression Range: --- → yes
Keywords: regression

@5
Thanks for the tip.

The patch in https://bugzilla.mozilla.org/show_bug.cgi?id=1721251 , comment 18 not only fixes that bug, but after I applied that patch this error also no longer occurs. I was able to successfully compile nightly. This is with all of the updates to the hg repository as of 20210722.

(In reply to mozilla@zenzen.monster from comment #7)

The patch in https://bugzilla.mozilla.org/show_bug.cgi?id=1721251 , comment 18 not only fixes that bug, but after I applied that patch this error also no longer occurs. I was able to successfully compile nightly. This is with all of the updates to the hg repository as of 20210722.

That's because the build uses a sysroot with an older version of glibc. But the problem still exists if using a newer glibc.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.