C 프로그래밍을 처음 사용합니다. Visual Studio 2010을 사용하여 C++ 코드에서 CPLEX 라이브러리를 실행하고 있습니다. 일부 작업을 수행 할 때 액세스 위반이 발생합니다.VS2010과 함께 CPLEX를 사용하여 액세스 위반 위치 작성
위의 위반은 mlock.c CRT 파일에 정의 된 void __cdecl _unlock 함수에보고됩니다. 특정 행은 LeaveCriticalSection (_locktable [locknum] .lock);입니다. 가 0xc0000005 : 액세스 위반 쓰기 위치 0xeb43c7c4
오류 메시지
는 0x0f63443b에서 처리되지 않은 예외입니다. 나의 해석은 그것이 메모리와 관련된 문제이지만 확실하지 않다는 것이다. 또한 코드에서 메모리 블록 0xeb43c7c4를 추적하는 방법을 모르겠습니다. 다음은 호출 스택입니다 :cplex124.dll!0fdd443b()
[Frames below may be incorrect and/or missing, no symbols loaded for cplex124.dll]
cplex124.dll!0fdd3bbb()
cplex124.dll!0fcd0610()
cplex124.dll!0fccfbfd()
cplex124.dll!0feb70fd()
cplex124.dll!0fede883()
> name.exe!_unlock(int locknum) Line 375 C
name.exe!_unlock_file2(int i, void * s) Line 356 + 0x9 bytes C
name.exe!printf(const char * format, ...) Line 68 + 0x10 bytes C
name.exe!main(int argc, char * * argv) Line 620 + 0xe bytes C++
name.exe!__tmainCRTStartup() Line 278 + 0x12 bytes C
kernel32.dll!7693ed6c()
ntdll.dll!7701377b()
ntdll.dll!7701374e()
_unlock의 소스로 mlock.c 파일로 제공 :
void __cdecl _unlock (
int locknum
)
{
/*
* leave the critical section.
*/
LeaveCriticalSection(_locktable[locknum].lock);
}
#ifdef _M_IX86
#pragma optimize("y",on)
#endif /* _M_IX86 */
그리고 printf와의 소스 파일 printf.c로에 있습니다 :
int __cdecl printf (
const char *format,
...
)
/*
* stdout 'PRINT', 'F'ormatted
*/
{
va_list arglist;
int buffing;
int retval;
_VALIDATE_RETURN((format != NULL), EINVAL, -1);
va_start(arglist, format);
_lock_str2(1, stdout);
__try {
buffing = _stbuf(stdout);
retval = _output_l(stdout,format,NULL,arglist);
_ftbuf(buffing, stdout);
}
__finally {
_unlock_str2(1, stdout);
}
return(retval);
}
프로젝트 속성에서 콘서트 파일 링크를 제거하면 동일한 오류 메시지가 표시되지만 e 파일을 _CRTIMP의 tidtable.c에 저장합니다. PFLS_GETVALUE_FUNCTION __cdecl __set_flsgetvalue() 온라인 : PFLS_GETVALUE_FUNCTION flsGetValue = FLS_GETVALUE;
나는 모든 조언을 부탁드립니다.
감사합니다.
특히'_unlock' 메서드와'printf'를 호출하는 코드를 제공 할 수 있습니까? – leander
질문에 소스를 추가했습니다. – user1372020
라이브러리 코드를 호출하기 전에 코드에서 스택 또는 힙이 손상되었을 가능성이 있습니다. 당신은 귀하가 작성한 코드와 귀하가 참조하는 "일부 행동"을 살펴 봐야합니다. –