使用带有VS2010的CPLEX访问违规写入位置

时间:2013-05-06 00:28:28

标签: c++ visual-studio-2010 cplex

我是C编程新手。我正在使用visual studio 2010在C ++代码中运行CPLEX库。我在执行某些操作时遇到访问冲突。

在CRT文件mlock.c中定义的函数void __cdecl _unlock中报告了违规。具体行是LeaveCriticalSection(_locktable [locknum] .lock);.

错误消息是0x0f63443b处的未处理异常:0xC0000005:访问冲突写入位置0xeb43c7c4。我的解释是,这是一个与记忆有关的问题,但我不确定。另外,我不知道如何在代码中跟踪内存块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);
}

如果我删除了项目属性中Concert文件的链接,我会收到相同的错误消息,但是在文件tidtable.c中,_CRTIMP PFLS_GETVALUE_FUNCTION __cdecl __set_flsgetvalue()在线:PFLS_GETVALUE_FUNCTION flsGetValue = FLS_GETVALUE;

我很感激任何建议。

感谢。

1 个答案:

答案 0 :(得分:-1)

Cplex是一个商业求解器库。他们可能会发布你提到的几个不同版本的DLL,以排列各种构建类型。

此外,此类型的库通常会为您定义的预处理器定义提供一些灵活性。有关详细信息,请参阅cplex文档。不匹配的定义可能会导致这样的错误,就像使用不支持使用库的多线程的运行时一样。

如果CPLEX证明有问题,我还建议查看GLPK,GNU线性编程套件,用于开源替代方案。