Repository: node
Issue: 16.11.1 cant build and execute on FreeBSD 13
Labels: build,freebsd

### Version

v16.10.0

### Platform

FreeBSD fundev.local 13.0-RELEASE-p4 FreeBSD 13.0-RELEASE-p4 #0: Tue Aug 24 07:33:27 UTC 2021     root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64

### Subsystem

_No response_

### What steps will reproduce the bug?

```shell
# portsnap fetch extract
# cd /usr/ports/www/node
# make install

  touch 1e84cbe79e4358925644ae4b811ed2b05dec0d7d.intermediate
  LD_LIBRARY_PATH=/usr/ports/www/node/work/node-v16.11.1/out/Release/lib.host:/usr/ports/www/node/work/node-v16.11.1/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../tools/v8_gypfiles; mkdir -p /usr/ports/www/node/work/node-v16.11.1/out/Release/obj.target/v8_snapshot/geni; "/usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot" --turbo_instruction_scheduling "--target_os=freebsd" "--target_arch=x64" --startup_src "/usr/ports/www/node/work/node-v16.11.1/out/Release/obj.target/v8_snapshot/geni/snapshot.cc" --embedded_variant Default --embedded_src "/usr/ports/www/node/work/node-v16.11.1/out/Release/obj.target/v8_snapshot/geni/embedded.S" --no-native-code-counters


#
# Fatal error in , line 0
# Check failed: reservation_.SetPermissions(unprotect_start, unprotect_size, FLAG_write_code_using_rwx ? PageAllocator::kReadWriteExecute : PageAllocator::kReadWrite).
#
#
#
#FailureMessage Object: 0x7ffffffc8880
==== C stack trace ===============================

    0x11784e3 <v8::base::debug::StackTrace::StackTrace()+0x13> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0x1177816 <v8::platform::(anonymous namespace)::PrintStackTrace()+0x26> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0x116c019 <V8_Fatal(char const*, ...)+0x139> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0xcbb37d <v8::internal::MemoryChunk::SetReadAndWritable()+0x9d> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0xc3d076 <v8::internal::Heap::UnprotectAndRegisterMemoryChunk(v8::internal::HeapObject, v8::internal::UnprotectMemoryOrigin)+0x76> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0xc0f007 <v8::internal::Heap::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment)+0x3d7> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0xc42cf4 <v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment)+0x24> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0xc42df1 <v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment)+0x21> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0xc0db29 <v8::internal::Factory::CodeBuilder::AllocateCode(bool)+0x49> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0xc0d30b <v8::internal::Factory::CodeBuilder::BuildInternal(bool)+0x23b> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0xc0e01e <v8::internal::Factory::CodeBuilder::Build()+0xe> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0x14787dd <v8::internal::SetupIsolateDelegate::PopulateWithPlaceholders(v8::internal::Isolate*)+0x1dd> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0x1478bd5 <v8::internal::SetupIsolateDelegate::SetupBuiltinsInternal(v8::internal::Isolate*)+0x35> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0xbdaaca <v8::internal::Isolate::Init(v8::internal::SnapshotData*, v8::internal::SnapshotData*, bool)+0x9da> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0xbda0df <v8::internal::Isolate::InitWithoutSnapshot()+0xf> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0xabcfd6 <v8::SnapshotCreator::SnapshotCreator(v8::Isolate*, long const*, v8::StartupData*)+0xa6> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
    0xfddee0 <v8::internal::CreateSnapshotDataBlobInternal(v8::SnapshotCreator::FunctionCodeHandling, char const*, v8::Isolate*)+0x40> at /usr/ports/www/node/work/node-v16.11.1/out/Release/mksnapshot
gmake[3]: *** [tools/v8_gypfiles/v8_snapshot.target.mk:17: 1e84cbe79e4358925644ae4b811ed2b05dec0d7d.intermediate] Trace/BPT trap (core dumped)
gmake[3]: *** Deleting file '1e84cbe79e4358925644ae4b811ed2b05dec0d7d.intermediate'
rm 4ec83c0bd4439a10b50dbe61de81288dac77db74.intermediate 4b0facea21f52ed9008b408f6febba102670fd64.intermediate 6e0b332922e1bd3867bce0de4a77215e7205dfde.intermediate
gmake[2]: *** [Makefile:110: node] Error 2
gmake[2]: Leaving directory '/usr/ports/www/node/work/node-v16.11.1'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/www/node
*** Error code 1

Stop.
make: stopped in /usr/ports/www/node
```

### How often does it reproduce? Is there a required condition?

If I install it from pkg.

```shell
# pkg install -y node
# pkg install -y npm
# pkg install -y yarn

# npm -v


#
# Fatal error in , line 0
# Check failed: reservation_.SetPermissions(unprotect_start, unprotect_size, FLAG_write_code_using_rwx ? PageAllocator::kReadWriteExecute : PageAllocator::kReadWrite).
#
#
#
#FailureMessage Object: 0x7fffffffc7d0
 1: 0x1829d61 node::NodePlatform::GetStackTracePrinter() [/usr/local/bin/node]
 2: 0x2284719 V8_Fatal(char const*, ...) [/usr/local/bin/node]
 3: 0x1b6b50d v8::internal::MemoryChunk::SetReadAndWritable() [/usr/local/bin/node]
 4: 0x1afe056 v8::internal::Heap::UnprotectAndRegisterMemoryChunk(v8::internal::HeapObject, v8::internal::UnprotectMemoryOrigin) [/usr/local/bin/node]
 5: 0x1ad5a19 v8::internal::Heap::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 6: 0x1b03bc4 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 7: 0x1b03cc1 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 8: 0x1ad45b9 v8::internal::Factory::CodeBuilder::AllocateCode(bool) [/usr/local/bin/node]
 9: 0x1ad3d9b v8::internal::Factory::CodeBuilder::BuildInternal(bool) [/usr/local/bin/node]
10: 0x1ad4a6e v8::internal::Factory::CodeBuilder::Build() [/usr/local/bin/node]
11: 0x20d0e5a v8::internal::RegExpMacroAssemblerX64::GetCode(v8::internal::Handle<v8::internal::String>) [/usr/local/bin/node]
12: 0x1e13533 v8::internal::RegExpCompiler::Assemble(v8::internal::Isolate*, v8::internal::RegExpMacroAssembler*, v8::internal::RegExpNode*, int, v8::internal::Handle<v8::internal::String>) [/usr/local/bin/node]
13: 0x1e2ed26 v8::internal::RegExpImpl::Compile(v8::internal::Isolate*, v8::internal::Zone*, v8::internal::RegExpCompileData*, v8::base::Flags<v8::internal::JSRegExp::Flag, int>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, bool, unsigned int&) [/usr/local/bin/node]
14: 0x1e2e4be v8::internal::RegExpImpl::CompileIrregexp(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, bool) [/usr/local/bin/node]
15: 0x1e2da69 v8::internal::RegExpImpl::IrregexpPrepare(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>) [/usr/local/bin/node]
16: 0x1e2dd62 v8::internal::RegExpImpl::IrregexpExec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>, v8::internal::RegExp::ExecQuirks) [/usr/local/bin/node]
Trace/BPT trap (core dumped)


# yarn -v


#
# Fatal error in , line 0
# Check failed: reservation_.SetPermissions(unprotect_start, unprotect_size, FLAG_write_code_using_rwx ? PageAllocator::kReadWriteExecute : PageAllocator::kReadWrite).
#
#
#
#FailureMessage Object: 0x7fffffffc860
 1: 0x1829d61 node::NodePlatform::GetStackTracePrinter() [/usr/local/bin/node]
 2: 0x2284719 V8_Fatal(char const*, ...) [/usr/local/bin/node]
 3: 0x1b6b50d v8::internal::MemoryChunk::SetReadAndWritable() [/usr/local/bin/node]
 4: 0x1afe056 v8::internal::Heap::UnprotectAndRegisterMemoryChunk(v8::internal::HeapObject, v8::internal::UnprotectMemoryOrigin) [/usr/local/bin/node]
 5: 0x1ad5a19 v8::internal::Heap::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 6: 0x1b03bc4 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 7: 0x1b03cc1 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 8: 0x1ad45b9 v8::internal::Factory::CodeBuilder::AllocateCode(bool) [/usr/local/bin/node]
 9: 0x1ad3d9b v8::internal::Factory::CodeBuilder::BuildInternal(bool) [/usr/local/bin/node]
10: 0x1ad4a6e v8::internal::Factory::CodeBuilder::Build() [/usr/local/bin/node]
11: 0x20d0e5a v8::internal::RegExpMacroAssemblerX64::GetCode(v8::internal::Handle<v8::internal::String>) [/usr/local/bin/node]
12: 0x1e13533 v8::internal::RegExpCompiler::Assemble(v8::internal::Isolate*, v8::internal::RegExpMacroAssembler*, v8::internal::RegExpNode*, int, v8::internal::Handle<v8::internal::String>) [/usr/local/bin/node]
13: 0x1e2ed26 v8::internal::RegExpImpl::Compile(v8::internal::Isolate*, v8::internal::Zone*, v8::internal::RegExpCompileData*, v8::base::Flags<v8::internal::JSRegExp::Flag, int>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, bool, unsigned int&) [/usr/local/bin/node]
14: 0x1e2e4be v8::internal::RegExpImpl::CompileIrregexp(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, bool) [/usr/local/bin/node]
15: 0x1e2da69 v8::internal::RegExpImpl::IrregexpPrepare(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>) [/usr/local/bin/node]
16: 0x1e2dd62 v8::internal::RegExpImpl::IrregexpExec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>, v8::internal::RegExp::ExecQuirks) [/usr/local/bin/node]
Trace/BPT trap (core dumped)
```


### What is the expected behavior?

_No response_

### What do you see instead?

_No response_

### Additional information

_No response_