Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.
首先,確定自己的程式碼正確,執行緒函式正確退出後,報這個錯,最後發現執行緒函式是這麼定義:
static DWORD WINAPI ServerWork(LPVOID lpParameter)
其中WINAPI為:
#define WINAPI __stdcall
把WINAPI去掉就好了。
解析:
主模組在呼叫Dll的匯出函式時會儲存返回地址在堆疊中(ESP+xxx)。函式呼叫返回時,會彈棧取得返回地址(ESP-xxx),從而返回到主模組。
vaule of ESP was not properly saved across a function call.
上面出現的錯誤是系統提示主模組呼叫前堆疊的指標(ESP),與呼叫匯出函式後的指標不符。
一般有兩種情況會出現類似錯誤。
1. Dll匯出函式宣告匯出方法,與主模組中宣告的匯入方法不一致。使得呼叫時引數的傳遞中,破壞了呼叫堆疊,出現錯誤。
2. Dll匯出函式本身破壞了呼叫堆疊。編碼中最一般的錯誤比如:物件(如CString)等。
解決方法:
針對第1種情況,請確定匯出方(Dll等)與匯入方(Exe等)的宣告保持一致。
對於第2種情況,請保證產生的物件都被安全的釋放。
備註:
可以試試下面的方法可以簡單的測試方法
將Dll的匯出函式定義成空處理(直接返回),如還出現錯誤,則是呼叫錯誤。
國外論壇不少人也提過這個問題將Calling Convention由原來的__cdecl
(/Gd)修改為__stdcall (/Gz),其實是因為IUnknown被轉換為IDispatch的問題。
http://blog.csdn.net/sysprogram/article/details/7737397
http://www.cnblogs.com/junchu25/archive/2012/08/10/2631133.html
相關文章
- 【React】Invalid hook call. Hooks can only be called inside of the body of a function component.ReactHookIDEFunction
- win10頻繁藍屏kernel security check failure修復方法Win10AI
- Http failure response 0 Unknown error 錯誤分析HTTPAIError
- win10頻繁藍色畫面kernel security check failure修復方法Win10AI
- [Vue warn]: Invalid prop: type check failed for prop "unlinkPanels". Expected Boolean, got String with value "true".VueAIBooleanGo
- Run-time Settings--General--Run Logic
- Spring Cloud Function現RCE 0-day漏洞SpringCloudFunction
- [InnoDB] Assertion failure: ut0ut.cc:553 thread 140235111884544【筆記】AIthread筆記
- vue報錯:[Vue warn]: Invalid prop: type check failed for prop "value". Expected Number, got String....VueAIGo
- An invalid XML character (Unicode: 0x10) was found in the value of attributeXMLUnicode
- Migration Of An Oracle Database Across OS Platforms [ID 733205.1]OracleDatabaseROSPlatform
- win10系統開啟VPNManage.exe出現藍屏kernel_security_check_failure如何解決Win10AI
- design for failureAI
- 監聽所有模型的 saved 事件模型事件
- win10系統開啟VPNManage.exe出現藍色畫面kernel_security_check_failure如何解決Win10AI
- onclick="return check()" 和 onclick="check()" 區別
- javascript 中function(){},new function(),new Function(),Function 摘錄JavaScriptFunction
- Check failed: status == CUDNN_STATUS_SUCCESS (4 vs. 0) CUDNN_STATUS_INTERNAL_ERRORAIDNNError
- Import Error: cannot import name ‘export_saved_modelImportErrorExport
- Error: Debug Failure at typeToStringErrorAI
- Preferred Read Failure GroupsAI
- Check if String is HappyAPP
- win10電腦開啟QQ提示Initialization failure:0x0000000C如何解決Win10AI
- MySQL: Incorrect string value: '\xF0\xA4\xBD\x82'分析MySql
- Android error “Could not get BatchedBridge, make sure your bundle is packaged properly” on start ofAndroidErrorBATPackage
- 使用parted建立大分割槽時 mkpart Warning: The resulting partition is not properly
- DRIVER_POWER_STATE_FAILUREAI
- Vagrant:NS_ERROR_FAILUREErrorAI
- [virtualbox] temporary failure in name resolutionAI
- win10系統執行qq提示initialization failure:0x0000000c的解決方法Win10AI
- CHECK_INTERFACE作用
- check_document_position
- 《Predict Anchor Links across Social Networks via an Embedding Approach》閱讀筆記ROSAPP筆記
- SAP WM中階Storage Type的Capacity Check – Usage check based on SUT
- SAP IDoc狀態70 - This IDoc is saved as the original of an edited document.
- mysql 報錯 Communications link failureMySqlAI
- 轉:Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:]AIUIViewIndex
- 【esp32 專案】使用esp32的wifiWiFi
- [LintCode] Check Full Binary Tree