在进程中隔离并多重实例化 C 库
我们有一个 C 库(.lib windows 和 .a linux),它只允许创建单例,并且一旦实例化就无法正确关闭(内存泄漏和线程保持活动状态)。
重写它并追查错误,是否有一种简单的方法可以在进程中隔离这种行为不当的代码,以便可以删除单例限制,并且可以将不干净的 tidyup 沙箱化?
我主要对任何正在进行的选项感兴趣,如果确实有的话。一个单独的进程显然可以解决这个问题,但会产生架构开销以允许远程控制库,除非有非常低影响的解决方案(它具有广泛的 API,因此维护大量粘合并不是特别有吸引力)。
We have a C library (.lib windows & .a linux) that only allows creation of a singleton and that also doesn't shut down properly (memory leaked and threads left alive) having been once instantiated.
Rewriting it and hunting down the bugs aside, is there a simple way to isolate this kind of misbehaving code in-process such that the singleton restriction can be removed, and the unclean tidyup can be sandboxed?
I am mainly interested in any in-process options, if indeed there are any. A seperate process would obviously solve it, but would incur an architectural overhead to allow remote control of the library unless there are very low impact solutions for that (it has a wide API, so maintaining a lot of glue is not particularly attractive).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,没有简单的方法可以做到这一点。对行为不良的库进行沙箱处理通常是使用单独的进程来完成的,您已经自己建议了这一点。像 Protocol Buffers 这样的 IPC 工具可能有助于定义和实现 IPC 协议。
Sorry, but there is no simple way to do this. Sandboxing badly behaving libraries is commonly done using separate processes, which you already suggested yourself. An IPC tool like Protocol Buffers might help in defining and implementing the IPC protocol.