Comments (5)
Thanks for the feedback. I'm going to try the suggested workaround for now, and I agree the proper thing to do is to de-singleton the runtime. If I ever get the resources to do so I might help contribute to this (after I get through my backlog of other things I want to upstream).
from iceoryx.
In this case I could at least guide you a little bit.
from iceoryx.
@gpalmer-latai there is a reason I don't like singletons.
I think I have a workaround and a solution. Since the destruction order of static variables is in reverse order of their construction, you could just call hasTerminationRequested
before initRuntime
.
Unfortunately, we need to reset the signal handler in the dtor, else if a signal was raised after the dtor it would access a destroyed semaphore. But it should be possible to just register an empty function as signal handler. AFAIK, this should prevent immediate termination and since the dtor of the SignalWatcher
runs after main
, it shouldn't have a negative effect. @elfenpiff what do you think?
There is a third solution but it is not yet fully workable for you. The experimental posh API does not use a singleton for the runtime but a local variable. With this, it is also guaranteed that the unregistering from RouDi is finished before the dtor of the static SignalWatcher
runs. Unfortunately, not all endpoints are already ported and request-response and the listener are not yet available.
from iceoryx.
Since the destruction order of static variables is in reverse order of their construction, you could just call hasTerminationRequested before initRuntime.
In one translation unit you are right, but when you have multiple ones this is no longer guaranteed. In this use case it should work but I wouldn't recommend this for production code. However, it is perfect for a quick intermediate solution to remove the annoying failures and gives us time to solve this issue cleanly.
But it should be possible to just register an empty function as signal handler. AFAIK, this should prevent immediate termination and since the dtor of the SignalWatcher runs after main, it shouldn't have a negative effect.
It would render the SignalWatcher useless in all other cases, but I agree that something like this is the only viable solution, when we have a singleton runtime. I am pointing this out because I think I used the SignalWatcher before to capture signals like SIGABRT when the shared memory is set to zero - to provide a useful error output to the user.
Also, I would not fix a design mistake we made - with the singleton - by adding another mistake in the SignalWatcher, which would then have surprising behavior. The contract is clear: register a signal, and when it goes out of scope, it restores the previous signal catching calls - maybe another instance has overridden some kind of signal handler, and with this change, we would break it.
There is a third solution but it is not yet fully workable for you. The experimental posh API does not use a singleton for the runtime but a local variable. With this, it is also guaranteed that the unregistering from RouDi is finished before the dtor of the static SignalWatcher runs. Unfortunately, not all endpoints are already ported and request-response and the listener are not yet available.
I would recommend this path. As far as I remember @elBoberido you mentioned that less than a week has to be invested to finish the featureset.
Otherwise, it feels like that we try to reduce bugs/technical debt by introducing even more technical debt.
from iceoryx.
@elfenpiff when my memories from creating the API for the Publisher
, Subscriber
and WaitSet
were fresh, it would have taken me about two days but now I guess it takes at least one more day to get into the details again.
from iceoryx.
Related Issues (20)
- Add 'iox' prefix to all functions and types in the platform abstraction
- SingleProcess example crashes on QNX HOT 4
- : backtrace: HOT 2
- Is `libatomic` still required to build Iceoryx? HOT 7
- Some questions about IndexQueue. HOT 10
- Feature request: print the number of ports in the introspection client
- 32-Bit Support
- How to handle messages in parallel with popo::listener? HOT 3
- Is there a cost comparison between serialization app and roudi with protobuf or other efficient implementation HOT 2
- iox-roudi throws POPO__CHUNK_LOCKING_ERROR when killing a process mid-publish HOT 6
- Ongoing Issue: Small Documentation Tasks
- publisher got error after loaned 8 sample HOT 2
- Out-of-bounds memory access in UsedChunkList HOT 9
- Request server received no valid server port from RouDi HOT 2
- It is possible to specify a queue size greater than 256 HOT 2
- Move iceoryx2 cxx addendum headers into iceoryx
- iox::function claims to support moving functions, but doesn't HOT 5
- Building iceoryx with bazel on Windows is broken
- Port iceoryx to bzlmod
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iceoryx.