Running plugins in a sandbox

后端 未结 3 1748
半阙折子戏
半阙折子戏 2021-02-15 16:49

I am designing a system in C/C++ which is extendible with all sort of plugins. There is a well defined C public API which mostly works with (const) char* and other

相关标签:
3条回答
  • 2021-02-15 17:35

    Simply put, you can't do that in the same process. If your plugins are written in C or C++, they can contain numerous sources of undefined behavior, meaning sources for undetectable unavoidable crashes. So you should either launch the plugins in their own processes like kassak suggested and let them crash if they want to, or use another language for your plugins, e.g. some intepreted scripting language like lua.

    0 讨论(0)
  • 2021-02-15 17:41

    Have a look at http://msdn.microsoft.com/en-us/library/1deeycx5(v=vs.90).aspx

    I use /EHa in one of my projects to help me catch exceptions from libraries that do stupid things. If you compile your code with this setting a normal try catch block will catch exceptions like devide by zero, etc.

    Not sure if there is some equivalent for this on Linux -- please let me know if there is..

    0 讨论(0)
  • 2021-02-15 17:49

    Make a wrapper process for plugin and communicate with that wrapper through IPC. In case of plugin failure your main process would be untouched

    0 讨论(0)
提交回复
热议问题