-2

For some reason, I need recodesign node.js.

I tried recodesign the node.js with my own mac appId with command codesign --deep --timestamp --options runtime -f -s 'Developer ID Application: xxxxxxxx' ~/Library/Keychains/login.keychain-db node.

Evertything looks fine, I can saw the node's signature with command codesign -d -vvvv node

but when I ran the recodesign node.js with node -p 'process' , I got this error:

#
# Fatal error in , line 0
# Check failed: reservation_.SetPermissions(unprotect_start, unprotect_size, FLAG_write_code_using_rwx ? PageAllocator::kReadWriteExecute : PageAllocator::kReadWrite).
#
#
#
#FailureMessage Object: 0x7ff7bc3c2a50
 1: 0x103c7c5e2 node::NodePlatform::GetStackTracePrinter()::$_3::__invoke() [/usr/local/lib/gsf/bin/node]
 2: 0x104d68133 V8_Fatal(char const*, ...) [/usr/local/lib/gsf/bin/node]
 3: 0x103fbb4d4 v8::internal::MemoryChunk::SetCodeModificationPermissions() [/usr/local/lib/gsf/bin/node]
 4: 0x103f38f89 v8::internal::Heap::UnprotectAndRegisterMemoryChunk(v8::internal::MemoryChunk*, v8::internal::UnprotectMemoryOrigin) [/usr/local/lib/gsf/bin/node]
 5: 0x103f0c8ac v8::internal::Heap::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/lib/gsf/bin/node]
 6: 0x103f3ed01 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/lib/gsf/bin/node]
 7: 0x103f0b810 v8::internal::Factory::CodeBuilder::AllocateCode(bool) [/usr/local/lib/gsf/bin/node]
 8: 0x103f0afa9 v8::internal::Factory::CodeBuilder::BuildInternal(bool) [/usr/local/lib/gsf/bin/node]
 9: 0x103de1ea3 v8::internal::baseline::BaselineCompiler::Build(v8::internal::Isolate*) [/usr/local/lib/gsf/bin/node]
10: 0x103df4063 v8::internal::GenerateBaselineCode(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SharedFunctionInfo>) [/usr/local/lib/gsf/bin/node]
11: 0x103e2e1c7 v8::internal::Compiler::CompileSharedWithBaseline(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::Compiler::ClearExceptionFlag, v8::internal::IsCompiledScope*) [/usr/local/lib/gsf/bin/node]
12: 0x103e2e553 v8::internal::Compiler::CompileBaseline(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag, v8::internal::IsCompiledScope*) [/usr/local/lib/gsf/bin/node]
13: 0x103dde048 v8::internal::baseline::BaselineBatchCompiler::CompileBatch(v8::internal::Handle<v8::internal::JSFunction>) [/usr/local/lib/gsf/bin/node]
14: 0x103dddf87 v8::internal::baseline::BaselineBatchCompiler::EnqueueFunction(v8::internal::Handle<v8::internal::JSFunction>) [/usr/local/lib/gsf/bin/node]
15: 0x1042f0861 v8::internal::(anonymous namespace)::BytecodeBudgetInterruptFromBytecode(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSFunction>) [/usr/local/lib/gsf/bin/node]
16: 0x1042ef453 v8::internal::Runtime_BytecodeBudgetInterruptFromBytecode(int, unsigned long*, v8::internal::Isolate*) [/usr/local/lib/gsf/bin/node]
17: 0x1046adff9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/lib/gsf/bin/node]

Below is my recodesign script:


# download node.js
curl https://nodejs.org/dist/v17.8.0/node-v17.8.0-darwin-arm64.tar.xz -o node-v17.8.0-darwin-arm64.tar.xz

tar -xJf node-v17.8.0-darwin-arm64.tar.xz

cd node-v17.8.0-darwin-arm64/bin

codesign --deep --timestamp --options runtime -f -s 'Developer ID Application: xxxxxxx Company Limited (xxxxxxxxx)' ~/Library/Keychains/login.keychain-db  node

codesign -d -vvvv node

what's the reason cause the error?

And how to fix this error?

Thanks

Rhain
  • 197
  • 1
  • 10

1 Answers1

0

I used blow command to recodesign node.js, it's looks work fine.

codesign --deep --timestamp --preserve-metadata=entitlements --options runtime -f -s 'Developer ID Application: xxxxxxxx' --entitlements node.entitlements ~/Library/Keychains/login.keychain-db node

--preserve-metadata=entitlements is the key。

Why there are someone who vote This question does not show any research effort; it is unclear or not useful. I research the question for a long time. if you think this question is useless, then why you donn't know how to solve this question?

These self righteous guys are so annoying.

Rhain
  • 197
  • 1
  • 10