Isolating and multiply instantiating a C library i

2020-07-09 05:28发布

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).

标签: c++ c ipc
1条回答
一纸荒年 Trace。
2楼-- · 2020-07-09 06:11

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.

查看更多
登录 后发表回答