VC6のstd::mapとDLL

仕事でおおはまりした人から

VC6std::mapをDLLとexeのインターフェースに用いるのはやばいからやめよう

exe側でコンストラクトしたオブジェクトをdll側からアクセスすると死んだりする

とのことでした。実際、最小限の再現ソースを動かすとAVになります。@VC6SP6
mapの実装もかなり読んだらしいです。私はテンプレートのソースは読めないのでうらやましい限りです。

さて、
すこしググってみると、作者のおじさん(Dinkum)のサイトにFixes for Library Bugs in VC++ V5.0/V6.0がありました。

Fix to < xtree >
The header < xtree > (original 25 June 1998) presented here eliminates all need for thread locks and corrects a number of thread-safety issues for template classes map, multimap, set, and multiset. It also solves some nasty problems with sharing these classes across DLLs. Note that no attempt has been made to retrofit the changes needed to make these template classes exception safe in the sense required by the final C++ Standard. (The headers map and set once presented here have been dropped as of 4 April 1999 — they were effectively unchanged over the shipped versions.)

だそうです。ようするにスレッドセーフでもないしDLLでも利用できないのを直してみました、という感じでしょうか。
どうやら以前は、他のたくさんのヘッダの修正版も公開していたようですが、現在はxtreeだけの修正で対策できるつもりのようです。
実際、xtreeを差し替えると、AVは発生しなくなります。
はたしてこの差し替えを標準的に利用してよいものかどうかが焦点になります。
このおじさんは、最近VC用STLのバグフィクスは行っていないようですし。
#そもそもMSがSTL周りのバグフィクスをどの程度やっているのかは不明ですが・・・

おかしな現象が出たら、(1)再現コードを書く、(2)テストスイートに追加する、(3)テストをこまめにメンテする、しかないのでしょう。