Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error on executing a hook (permissions?) #6

Closed
Zverik opened this issue Jan 10, 2025 · 3 comments
Closed

Fatal error on executing a hook (permissions?) #6

Zverik opened this issue Jan 10, 2025 · 3 comments

Comments

@Zverik
Copy link

Zverik commented Jan 10, 2025

I'm not sure what is happening. My hooks file:

[[hooks]]
folder = "/opt/sync/zettel"
event = "folder_down_sync_done"
allow_concurrent = false
command = "/srv/update_izv.sh"

I have done sudo -u <stfed_user> /srv/update_izv.sh from a random directory, worked file.

I'm running stfed as a systemd service. Here is an excerpt from its log after we got an update:

Jan 10 17:54:23 zverev stfed[547730]: Host: 127.0.0.1:8384
Jan 10 17:54:23 zverev stfed[547730]: User-Agent: stfed/1.1.0
Jan 10 17:54:23 zverev stfed[547730]: Accept: */*
Jan 10 17:54:23 zverev stfed[547730]: X-API-Key: REMOVED
Jan 10 17:54:23 zverev stfed[547730]: DEBUG [ureq::response] Chunked body in response
Jan 10 17:54:23 zverev stfed[547730]: DEBUG [ureq::unit] response 200 to GET http://127.0.0.1:8384/rest/events?since=13&limit=1&events=ItemFinished%2CFolderSummary%2CLocalChangeDetected%2CConfigS>
Jan 10 17:54:23 zverev stfed[547730]: DEBUG [ureq::pool] adding stream to pool: http|127.0.0.1|8384 -> Stream(TcpStream { addr: 127.0.0.1:41836, peer: 127.0.0.1:8384, fd: 3 })
Jan 10 17:54:23 zverev stfed[547730]: INFO  [stfed] New event: FolderDownSyncDone { folder: "/opt/sync/zettel" }
Jan 10 17:54:23 zverev stfed[547730]: INFO  [stfed::hook] Running hook: FolderHook { folder: "/opt/sync/zettel", event: FolderDownSyncDone, filter: None, command: ["/srv/update_izv.sh"], allow_concurrent: Some(false) } with path None and folder "/opt/sync/zettel"
Jan 10 17:54:23 zverev stfed[547730]: DEBUG [stfed::syncthing] GET "http://127.0.0.1:8384/rest/events?since=14&limit=1&events=ItemFinished%2CFolderSummary%2CLocalChangeDetected%2CConfigSaved&timeout=3600
Jan 10 17:54:23 zverev stfed[547730]: DEBUG [ureq::pool] pulling stream from pool: http|127.0.0.1|8384 -> Stream(TcpStream { addr: 127.0.0.1:41836, peer: 127.0.0.1:8384, fd: 3 })
Jan 10 17:54:23 zverev stfed[547730]: DEBUG [ureq::unit] sending request (reused connection) GET http://127.0.0.1:8384/rest/events?since=14&limit=1&events=ItemFinished%2CFolderSummary%2CLocalChan>
Jan 10 17:54:23 zverev stfed[547730]: DEBUG [ureq::unit] writing prelude: GET /rest/events?since=14&limit=1&events=ItemFinished%2CFolderSummary%2CLocalChangeDetected%2CConfigSaved&timeout=3600 HT>
Jan 10 17:54:23 zverev stfed[547730]: Host: 127.0.0.1:8384
Jan 10 17:54:23 zverev stfed[547730]: User-Agent: stfed/1.1.0
Jan 10 17:54:23 zverev stfed[547730]: Accept: */*
Jan 10 17:54:23 zverev stfed[547730]: X-API-Key: REMOVED
Jan 10 17:54:23 zverev stfed[547730]: DEBUG [ureq::response] Chunked body in response
Jan 10 17:54:23 zverev stfed[547730]: DEBUG [ureq::unit] response 200 to GET http://127.0.0.1:8384/rest/events?since=14&limit=1&events=ItemFinished%2CFolderSummary%2CLocalChangeDetected%2CConfigS>
Jan 10 17:54:23 zverev stfed[547851]: #
Jan 10 17:54:23 zverev stfed[547851]: # Fatal error in , line 0
Jan 10 17:54:23 zverev stfed[547851]: # Check failed: 12 == (*__errno_location ()).
Jan 10 17:54:23 zverev stfed[547851]: #
Jan 10 17:54:23 zverev stfed[547851]: #
Jan 10 17:54:23 zverev stfed[547851]: #
Jan 10 17:54:23 zverev stfed[547851]: #FailureMessage Object: 0x7ffeecdce390
Jan 10 17:54:23 zverev stfed[547851]: ----- Native stack trace -----
Jan 10 17:54:23 zverev stfed[547851]:  1: 0x101c1a1  [node]
Jan 10 17:54:23 zverev stfed[547851]:  2: 0x27bb9eb V8_Fatal(char const*, ...) [node]
Jan 10 17:54:23 zverev stfed[547851]:  3: 0x27c6ba7 v8::base::OS::SetPermissions(void*, unsigned long, v8::base::OS::MemoryPermission) [node]
Jan 10 17:54:23 zverev stfed[547851]:  4: 0x14ea4c5 v8::internal::MemoryAllocator::SetPermissionsOnExecutableMemoryChunk(v8::internal::VirtualMemory*, unsigned long, unsigned long, unsigned long)>
Jan 10 17:54:23 zverev stfed[547851]:  5: 0x14ea7e1 v8::internal::MemoryAllocator::AllocateAlignedMemory(unsigned long, unsigned long, unsigned long, v8::internal::AllocationSpace, v8::internal::>
Jan 10 17:54:23 zverev stfed[547851]:  6: 0x14eaa54 v8::internal::MemoryAllocator::AllocateUninitializedChunkAt(v8::internal::BaseSpace*, unsigned long, v8::internal::Executability, unsigned long>
Jan 10 17:54:23 zverev stfed[547851]:  7: 0x14eac5c v8::internal::MemoryAllocator::AllocatePage(v8::internal::MemoryAllocator::AllocationMode, v8::internal::Space*, v8::internal::Executability) [>
Jan 10 17:54:23 zverev stfed[547851]:  8: 0x15082a0 v8::internal::PagedSpaceBase::TryExpand(v8::internal::LocalHeap*, v8::internal::AllocationOrigin) [node]
Jan 10 17:54:23 zverev stfed[547851]:  9: 0x14b7413 v8::internal::PagedSpaceAllocatorPolicy::RefillLab(int, v8::internal::AllocationOrigin) [node]
Jan 10 17:54:23 zverev stfed[547851]: 10: 0x14b55db v8::internal::MainAllocator::AllocateRawSlow(int, v8::internal::AllocationAlignment, v8::internal::AllocationOrigin) [node]
Jan 10 17:54:23 zverev stfed[547851]: 11: 0x14548d6 v8::internal::Factory::CodeBuilder::AllocateUninitializedInstructionStream(bool) [node]
Jan 10 17:54:23 zverev stfed[547851]: 12: 0x146c509 v8::internal::Factory::CodeBuilder::BuildInternal(bool) [node]
Jan 10 17:54:23 zverev stfed[547851]: 13: 0x19e2172 v8::internal::baseline::BaselineCompiler::Build(v8::internal::LocalIsolate*) [node]
Jan 10 17:54:23 zverev stfed[547851]: 14: 0x12b0daa v8::internal::GenerateBaselineCode(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SharedFunctionInfo>) [node]
Jan 10 17:54:23 zverev stfed[547851]: 15: 0x130f81b v8::internal::Compiler::CompileSharedWithBaseline(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal:>
Jan 10 17:54:23 zverev stfed[547851]: 16: 0x130fac2 v8::internal::Compiler::CompileBaseline(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ClearEx>
Jan 10 17:54:23 zverev stfed[547851]: 17: 0x19df60b v8::internal::baseline::BaselineBatchCompiler::CompileBatch(v8::internal::Handle<v8::internal::JSFunction>) [node]
Jan 10 17:54:23 zverev stfed[547851]: 18: 0x13fb36f v8::internal::TieringManager::OnInterruptTick(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::CodeKind) [node]
Jan 10 17:54:23 zverev stfed[547851]: 19: 0x18b460b  [node]
Jan 10 17:54:23 zverev stfed[547851]: 20: 0x18b6254 v8::internal::Runtime_BytecodeBudgetInterruptWithStackCheck_Ignition(int, unsigned long*, v8::internal::Isolate*) [node]
Jan 10 17:54:23 zverev stfed[547851]: 21: 0x1e12476  [node]
Jan 10 17:54:23 zverev stfed[547850]: Trace/breakpoint trap (core dumped)
Jan 10 17:54:24 zverev stfed[547730]: INFO  [stfed::hook] Process exited with code Some(133)
@desbma
Copy link
Owner

desbma commented Jan 10, 2025

Does your systemd service has hardening options set?
stfed does nothing special when executing the command, apart from closing stdin.

EDIT: I have taken the liberty to edit the log have posted, because it had your Syncthing API key in clear text.

@desbma
Copy link
Owner

desbma commented Jan 10, 2025

v8::internal::MemoryAllocator::SetPermissionsOnExecutableMemoryChunk

From this I think it's highly likely that systemd hardening is causing your v8 based program to crash.
Try commenting out MemoryDenyWriteExecute=true in the stfed service file.

@Zverik
Copy link
Author

Zverik commented Jan 10, 2025

Yaaay, it helped! Setting the parameter to false made the error go away. Thank you Maxime!

(I have also changed my API key.)

@Zverik Zverik closed this as completed Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants