Skip to content

node shmem: Reset Sample::signals before writing to shared memory - #1020

Merged
stv0g merged 1 commit into
VILLASframework:masterfrom
leonardocarreras:fix-shmem-sample-signal
Jul 30, 2026
Merged

node shmem: Reset Sample::signals before writing to shared memory#1020
stv0g merged 1 commit into
VILLASframework:masterfrom
leonardocarreras:fix-shmem-sample-signal

Conversation

@leonardocarreras

Copy link
Copy Markdown
Contributor

The shmem node writes samples whose signals field is a std::shared_ptr into the writer's heap. A reader in another process dereferences that pointer while copying the sample and crashes.

Discovered when using two villas-node processes with shmem, it segfaults at the first read.

@stv0g stv0g left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread lib/nodes/shmem.cpp Outdated
@leonardocarreras
leonardocarreras force-pushed the fix-shmem-sample-signal branch from 3a51577 to f27f241 Compare July 16, 2026 10:10
@leonardocarreras

leonardocarreras commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

I believe this change is better located in shmem_int_write:

https://github.com/leonardocarreras/node/blob/cd0ac2b4577057a3c384f2c2148fa7f78382b374/lib/shmem.cpp#L190

Hi @stv0g, I agree with your suggestion. I moved it there and tested again. Thanks also for the style comments.

Signed-off-by: Leonardo Carreras <leonardo.carreras@eonerc.rwth-aachen.de>
@leonardocarreras
leonardocarreras force-pushed the fix-shmem-sample-signal branch from 88bf7e8 to 6c96437 Compare July 30, 2026 08:32
@stv0g
stv0g merged commit 50d77fa into VILLASframework:master Jul 30, 2026
91 of 93 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working node::shmem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants