Bug 271838 - lang/v8: fails with kern.elf64.allow_wx=0 but elfctl -e +wxneeded doesn't help
Summary: lang/v8: fails with kern.elf64.allow_wx=0 but elfctl -e +wxneeded doesn't help
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Po-Chuan Hsieh
URL:
Keywords:
Depends on:
Blocks: 252629
  Show dependency treegraph
 
Reported: 2023-06-05 12:28 UTC by Jan Beich
Modified: 2023-08-28 18:08 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (sunpoet)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2023-06-05 12:28:32 UTC
Ports with embedded v8 either don't build or don't run. Some like www/node* (bug 261952) can be worked around via USES=elfctl.

$ sysctl kern.elf32.allow_wx=1
$ sysctl kern.elf64.allow_wx=1
$ pkg install v8

$ proccontrol -m wxmap v8_shell
V8 version 10.4.132.20 [sample shell]
> ^D

$ elfctl -e +wxneeded `which v8_shell`
$ v8_shell


#
# Fatal error in , line 0
# Check failed: 12 == (* __error()).
#
#
#
#FailureMessage Object: 0x2f206175e170
==== C stack trace ===============================

    0x2f2066df6053 <v8::base::debug::StackTrace::StackTrace()+0x13> at /usr/local/lib/libv8_libbase.so
    0x2f2064e31cab <v8::platform::DefaultPlatform::GetStackTracePrinter()+0x3b> at /usr/local/lib/libv8_libplatform.so
    0x2f2066de91a5 <V8_Fatal(char const*, ...)+0x145> at /usr/local/lib/libv8_libbase.so
    0x2f2066df4a80 <v8::base::OS::SetPermissions(void*, unsigned long, v8::base::OS::MemoryPermission)+0x50> at /usr/local/lib/libv8_libbase.so
    0x2f20636833a6 <v8::internal::MemoryAllocator::Unmapper::EnsureUnmappingCompleted()+0x566> at /usr/local/lib/libv8.so
    0x2f20636831c5 <v8::internal::MemoryAllocator::Unmapper::EnsureUnmappingCompleted()+0x385> at /usr/local/lib/libv8.so
    0x2f206368350d <v8::internal::MemoryAllocator::Unmapper::EnsureUnmappingCompleted()+0x6cd> at /usr/local/lib/libv8.so
    0x2f2063683a12 <v8::internal::MemoryAllocator::AllocatePage(v8::internal::MemoryAllocator::AllocationMode, v8::internal::Space*, v8::internal::Executability)+0x102> at /usr/local/lib/libv8.so
    0x2f2063695fac <v8::internal::PagedSpaceBase::Expand()+0x2c> at /usr/local/lib/libv8.so
    0x2f2063697115 <v8::internal::PagedSpaceBase::RawRefillLabMain(int, v8::internal::AllocationOrigin)+0x1a5> at /usr/local/lib/libv8.so
    0x2f2063696f61 <v8::internal::PagedSpaceBase::RefillLabMain(int, v8::internal::AllocationOrigin)+0x21> at /usr/local/lib/libv8.so
    0x2f2063602e04 <v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment)+0x214> at /usr/local/lib/libv8.so
    0x2f2063603e23 <v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment)+0x33> at /usr/local/lib/libv8.so
    0x2f206399ba87 <v8::internal::Deserializer<v8::internal::Isolate>::PostProcessNewJSReceiver(v8::internal::Map, v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::JSReceiver, v8::internal::InstanceType, v8::internal::SnapshotSpace)+0x5f7> at /usr/local/lib/libv8.so
    0x2f20639986ae <v8::internal::Deserializer<v8::internal::Isolate>::ReadObject(v8::internal::SnapshotSpace)+0x11e> at /usr/local/lib/libv8.so
    0x2f206399a1f0 <v8::internal::Deserializer<v8::internal::Isolate>::ReadData(v8::internal::Handle<v8::internal::HeapObject>, int, int)+0xd00> at /usr/local/lib/libv8.so
    0x2f206399941e <v8::internal::Deserializer<v8::internal::Isolate>::VisitRootPointers(v8::internal::Root, char const*, v8::internal::FullObjectSlot, v8::internal::FullObjectSlot)+0x3e> at /usr/local/lib/libv8.so
    0x2f2063618d86 <v8::internal::Heap::InSpaceSlow(unsigned long, v8::internal::AllocationSpace) const+0x276> at /usr/local/lib/libv8.so
    0x2f20639ac387 <v8::internal::WarmUpSnapshotDataBlobInternal(v8::StartupData, char const*)+0x1d7> at /usr/local/lib/libv8.so
    0x2f20635a5255 <v8::internal::Isolate::Init(v8::internal::SnapshotData*, v8::internal::SnapshotData*, v8::internal::SnapshotData*, bool)+0xf95> at /usr/local/lib/libv8.so
    0x2f20635a56d9 <v8::internal::Isolate::InitWithSnapshot(v8::internal::SnapshotData*, v8::internal::SnapshotData*, v8::internal::SnapshotData*, bool)+0x9> at /usr/local/lib/libv8.so
    0x2f20639a9c84 <v8::internal::Checksum(v8::base::Vector<unsigned char const>)+0x474> at /usr/local/lib/libv8.so
    0x2f2063486507 <v8::Isolate::Initialize(v8::Isolate*, v8::Isolate::CreateParams const&)+0x1b7> at /usr/local/lib/libv8.so
    0x2f206348670d <v8::Isolate::New(v8::Isolate::CreateParams const&)+0x1d> at /usr/local/lib/libv8.so
Trace/BPT trap
Comment 1 Jan Beich freebsd_committer freebsd_triage 2023-06-05 12:29:57 UTC
Typo: s/allow_wx=1/allow_wx=0/ (see also bug 191677)
Comment 2 Jan Beich freebsd_committer freebsd_triage 2023-06-05 12:46:34 UTC
(In reply to Jan Beich from comment #0)
> Ports with embedded v8 either don't build or don't run.

Examples:
- devel/electron24
- games/punchy
- www/chromium (Aw, Snap!)
- www/deno
Comment 3 Robert Nagy freebsd_committer freebsd_triage 2023-08-28 18:08:23 UTC
In this case, v8 fails because of an mprotect()

 40955 v8_shell CALL  mprotect(0x3592e0004000,0x3b000,0x7<PROT_READ|PROT_WRITE|PROT_EXEC>)
 40955 v8_shell RET   mprotect -1 errno 13 Permission denied

According to elfctl:
wxneeded        'Requires W+X mappings' is set.