• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            C++ library系列 -- static destructors in multiple threads

              In VC++ 8.0, while  code compiled with /clr or /clr:pure, static destructors sometimes would not being properly called before process exites in multiple threads.

              CRT incorrectly set a lock at _global_unlock which resulted in such issue.

              In CLR-mixed mode, during the inialization of static local object, CRT would call _atexit_m(_CPVFV func) in msilexit.cpp to register a special __clrcall callback function which would be called back to destroy such static object when the current AppDomain quited.

              In the multithread environment, _atexit_helper which was invoked by _atexit_m, could register such callbace function successfully because it had been guarded by __global_lock() and __global_unlock(). But in the same environment, the _atexit_m would fail to assign the correct value to __onexitbegin_m and __onexitend_m.

              __onexitbegin_m and __onexitend_m were shared by the different threads; It's the key point of such issue. For example, the following statements,

              __onexitbegin_m = (_CPVFV *)_encode_pointer(onexitbegin_m);
              __onexitend_m = (_CPVFV *)_encode_pointer(onexitend_m);

            should also guarded by __global_lock() and __global_unlock() or other syn primitives.


            __global_lock();
            __onexitbegin_m = (_CPVFV *)_encode_pointer(onexitbegin_m);
            __onexitend_m   = (_CPVFV *)_encode_pointer(onexitend_m);
            __global_unlock();


            extern "C" int __clrcall _atexit_m(_CPVFV func)
            {
             MANAGED_ASSERT(AppDomain::CurrentDomain->IsDefaultAppDomain(), "This fuction must be called in the default domain");

             __global_lock();
             _CPVFV* onexitbegin_m = (_CPVFV*)_decode_pointer(__onexitbegin_m);
             _CPVFV* onexitend_m = (_CPVFV*)_decode_pointer(__onexitend_m);
             __global_unlock();

             int retval = _atexit_helper((_CPVFV)_encode_pointer(func), &__exit_list_size, &onexitend_m, &onexitbegin_m);

             __global_lock();
             __onexitbegin_m = (_CPVFV*)_encode_pointer(onexitbegin_m);
             __onexitend_m  = (_CPVFV*)_encode_pointer(onexitend_m);
             __global_unlock();

             return retval;
            }

            posted on 2011-02-08 20:57 flagman 閱讀(2105) 評論(0)  編輯 收藏 引用 所屬分類: C++并發和并行 concurrency & parallelism

            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導航

            統計

            常用鏈接

            留言簿(1)

            隨筆分類

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久天天躁狠狠躁夜夜av浪潮 | 久久久综合香蕉尹人综合网| a高清免费毛片久久| 欧美亚洲另类久久综合| 亚洲国产精品无码久久九九| 少妇久久久久久久久久| 94久久国产乱子伦精品免费| 三级片免费观看久久| 久久精品国产精品亚洲毛片| 中文字幕成人精品久久不卡| 久久久久久久久久久| 99久久亚洲综合精品成人| 欧美一区二区久久精品| 久久久国产精品网站| 亚洲精品无码久久久影院相关影片| 99久久亚洲综合精品网站| 久久婷婷五月综合国产尤物app| 久久久久国产一级毛片高清板 | 欧美精品九九99久久在观看| 嫩草影院久久99| 久久久精品国产sm调教网站| 久久午夜无码鲁丝片秋霞| 精品久久久久久国产免费了| 久久精品成人免费看| 久久九九精品99国产精品| 思思久久99热免费精品6| 99久久人人爽亚洲精品美女| 久久99精品国产麻豆| 久久久久成人精品无码中文字幕| 人人妻久久人人澡人人爽人人精品| 久久久久亚洲精品无码网址 | av午夜福利一片免费看久久| 久久久无码精品亚洲日韩蜜臀浪潮| 精品人妻伦九区久久AAA片69| 国产A级毛片久久久精品毛片| 日本免费久久久久久久网站| 久久久久久九九99精品| 狠狠狠色丁香婷婷综合久久五月 | 香港aa三级久久三级老师2021国产三级精品三级在 | 国产美女久久久| 国产精品午夜久久|