Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

access violation when linking with VisualStudio 2012 binary

Wiebke_T_
Beginner
4,721 Views

Hi!

I compiled and linked an executable (let's call it blah) against a static library (let's call it asdf) that is built with Intel Composer XE 2013 SP1 Update 3 as well as some other static libraries that were built with Visual Studio 2012 (parameters see below).

When I execute blah, I get an access violation out of one of the libraries built with VS2012. (It is a logger library and the error only happens when something is actually printed to stdout). That library was built with the same compiler settings as blah had before its conversion to an Intel compiler solution (except for /Qvc11).

Of course the access violation does not occur when I build the same solution with the Visual Studio compiler, otherwise I wouldn't be writing this post. :)

I suspect that the binaries are somehow incompatible (the access violation happens when I jump OUT of a method that printed a log message).

Am I missing additional compiler options for vc110 compatibility?

 

--------------------------------------

Here are the details:

The original VS solution of blah had these compiler parameters

/MP /GS /TP /W4 /Zc:wchar_t (various include directories) /Zi /Gm- /O2 /Fd"blah.pdb" /D "WIN32" /D "_WINDOWS" /D "_SCL_SECURE_NO_WARNINGS" /D "_CRT_SECURE_NO_WARNINGS" /D "STRICT" /D "NOMINMAX" /D "_VARIADIC_MAX=10" /D "BOOST_ALL_NO_LIB" /D "__WIN32__" /D "__x86__" /D "__NT__" /D "__OSVERSION__=4" /D "NDEBUG" /D "_ITERATOR_DEBUG_LEVEL=0" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /MD /Fa"Release" /EHa /nologo /Fo"blah.dir\Release\" /Fp"blah.dir\Release\blah.pch"  /bigobj

and converted into an Intel compiler solution with these compiler parameters:

/MP /GS /TP /W4 /Zc:wchar_t (various include directories) /Zi /O2 /Fd"blah.pdb" /D "WIN32" /D "_WINDOWS" /D "_SCL_SECURE_NO_WARNINGS" /D "_CRT_SECURE_NO_WARNINGS" /D "STRICT" /D "NOMINMAX" /D "_VARIADIC_MAX=10" /D "BOOST_ALL_NO_LIB" /D "__WIN32__" /D "__x86__" /D "__NT__" /D "__OSVERSION__=4" /D "NDEBUG" /D "_ITERATOR_DEBUG_LEVEL=0" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /Zc:forScope /GR /MD /Fa"Release" /EHa /nologo /Fo"blah.dir\Release\" /Fp"blah.pch"  /bigobj  /Qvc11

Here are the linker parameters for blah (they don't change when converting to an Intel C++ solution). Only asdf.lib was built with the Intel compiler as well, all other libs (foo?.lib) were built with Visual Studio 2012. The access violation happens in "badlibrary.lib". (I changed all the names of our own libraries):

/OUT:"blah.exe" /MANIFEST /NXCOMPAT /PDB:"blah.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib" "asdf.lib" "badlibrary.lib" "foo0.lib" "gtest.lib" "gtest_main.lib" "chemicaltools.lib" "foo1.lib" "libboost_chrono-vc110-mt-1_55.lib" "foo2.lib" "bdal-sysutils.lib" "foo3.lib" "foo4.lib" "libboost_thread-vc110-mt-1_55.lib" "libboost_date_time-vc110-mt-1_55.lib" "libboost_filesystem-vc110-mt-1_55.lib" "libboost_regex-vc110-mt-1_55.lib" "mkl_intel_lp64.lib" "libboost_system-vc110-mt-1_55.lib" "mkl_sequential.lib" "mkl_core.lib" /STACK:"10000000" /IMPLIB:"blah.lib" /DEBUG /MACHINE:X64 /OPT:REF /INCREMENTAL:NO /PGD:"blah.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"blah.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:(various lib paths) /TLBID:1

 

0 Kudos
1 Solution
Sukruth_H_Intel
Employee
4,644 Views

Hi wiebke,

                I have escalated this issue to our engineering team. But i would recommend you to lodge this issue in IPS (Intel Premier Support) for better tracking.

Regards,

Sukruth H V

View solution in original post

0 Kudos
71 Replies
Bernard
Valued Contributor I
1,984 Views

Can you post call stack?

0 Kudos
QIAOMIN_Q_
New Contributor I
1,984 Views

Hello,

Does this only happens with update3 and no problem with SP1 compiler fomer updates ?

0 Kudos
Bernard
Valued Contributor I
1,984 Views

>>>The access violation happens in "badlibrary.lib". >>>

So av happens inside your own library?

0 Kudos
Wiebke_T_
Beginner
1,984 Views

@iliyapolak: Hard to say where the access violation happens. It occurs when it jumps OUT of our own library. It is a std c++ library. Before the exception occurs, the debugger jumps back and forth between lines, so somehow, when jumping out of the "badlibrary" function, it messes up the stack pointer I think. Below is a stack frame from when it jumps out of the method for the first time (and steps onto one line BEFORE the line where it goes wrong. (The stack is from a gtest where I did nothing except that library call. There is no multithreading, so it cannot legally step BACKWARDS in the code.)

@QIAOMIN Q: I don't know, I haven't tried with the former updates. Do you think it is worth to reinstall an old one? I used the newest because  I need VS2012 compatibility.

...um.... the forum software says my submission contains invalid characters, so I'm trying without the call stack at first... will try with next post.

 

0 Kudos
Wiebke_T_
Beginner
1,984 Views
---- call stack ----- > formulascoringtests.exe!boost_optional_detail::boost_optional_detail::() Line 42 C++ msvcr110d.dll!_CallSettingFrame() Line 51 Unknown msvcr110d.dll!__FrameUnwindToState(unsigned __int64 * pRN=0x00000000009baef8, _xDISPATCHER_CONTEXT * pDC=0x00000000009bb0c0, const _s_FuncInfo * pFuncInfo=0x000000014245f9d0, int targetState=-1) Line 1064 C++ msvcr110d.dll!__FrameUnwindToEmptyState(unsigned __int64 * pRN=0x00000000009bafe0, _xDISPATCHER_CONTEXT * pDC=0x00000000009bb0c0, const _s_FuncInfo * pFuncInfo=0x000000014245f9d0) Line 158 C++ msvcr110d.dll!__InternalCxxFrameHandler(EHExceptionRecord * pExcept=0x00000000009bc3b0, unsigned __int64 * pRN=0x00000000009bafe0, _CONTEXT * pContext=0x00000000009bb1b0, _xDISPATCHER_CONTEXT * pDC=0x00000000009bb0c0, const _s_FuncInfo * pFuncInfo=0x000000014245f9d0, int CatchDepth=0, unsigned __int64 * pMarkerRN=0x0000000000000000, unsigned char recursive='\0') Line 393 C++ msvcr110d.dll!__CxxFrameHandler3(EHExceptionRecord * pExcept=0x00000000009bc3b0, unsigned __int64 RN=10220864, _CONTEXT * pContext=0x00000000009bb1b0, _xDISPATCHER_CONTEXT * pDC=0x00000000009bb0c0) Line 193 C++ ntdll.dll!RtlpExecuteHandlerForUnwind () Unknown ntdll.dll!RtlUnwindEx () Unknown kernel32.dll!000000007785050e() Unknown msvcr110d.dll!__C_specific_handler(_EXCEPTION_RECORD * ExceptionRecord=0x00000000009bc3b0, void * EstablisherFrame=0x00000000009bf710, _CONTEXT * ContextRecord=0x00000000009bbec0, _DISPATCHER_CONTEXT * DispatcherContext=0x00000000009bb870) Line 212 C ntdll.dll!RtlpExecuteHandlerForException () Unknown ntdll.dll!RtlDispatchException () Unknown ntdll.dll!KiUserExceptionDispatch () Unknown msvcp110d.dll!std::ios_base::_Ios_base_dtor(std::ios_base * _This=0x00000000009bf720) Line 41 C++ msvcp110d.dll!std::ios_base::~ios_base() Line 533 C++ msvcp110d.dll!std::basic_ios >::~basic_ios >() Line 40 C++ formulascoringtests.exe!std::basic_ostringstream, std::allocator >::~basic_ostringstream() Line 543 C++ msvcr110d.dll!_CallSettingFrame() Line 51 Unknown msvcr110d.dll!__FrameUnwindToState(unsigned __int64 * pRN=0x00000000009bc648, _xDISPATCHER_CONTEXT * pDC=0x00000000009bc810, const _s_FuncInfo * pFuncInfo=0x0000000142ac4698, int targetState=-1) Line 1064 C++ msvcr110d.dll!__FrameUnwindToEmptyState(unsigned __int64 * pRN=0x00000000009bc730, _xDISPATCHER_CONTEXT * pDC=0x00000000009bc810, const _s_FuncInfo * pFuncInfo=0x0000000142ac4698) Line 158 C++ msvcr110d.dll!__InternalCxxFrameHandler(EHExceptionRecord * pExcept=0x00000000009bdb00, unsigned __int64 * pRN=0x00000000009bc730, _CONTEXT * pContext=0x00000000009bd010, _xDISPATCHER_CONTEXT * pDC=0x00000000009bc810, const _s_FuncInfo * pFuncInfo=0x0000000142ac4698, int CatchDepth=0, unsigned __int64 * pMarkerRN=0x0000000000000000, unsigned char recursive='\0') Line 393 C++ msvcr110d.dll!__CxxFrameHandler3(EHExceptionRecord * pExcept=0x00000000009bdb00, unsigned __int64 RN=10220368, _CONTEXT * pContext=0x00000000009bd010, _xDISPATCHER_CONTEXT * pDC=0x00000000009bc810) Line 193 C++ ntdll.dll!RtlpExecuteHandlerForUnwind () Unknown ntdll.dll!RtlUnwindEx () Unknown kernel32.dll!000000007785050e() Unknown msvcr110d.dll!__C_specific_handler(_EXCEPTION_RECORD * ExceptionRecord=0x00000000009bdb00, void * EstablisherFrame=0x00000000009bf710, _CONTEXT * ContextRecord=0x00000000009bd610, _DISPATCHER_CONTEXT * DispatcherContext=0x00000000009bcfc0) Line 212 C ntdll.dll!RtlpExecuteHandlerForException () Unknown ntdll.dll!RtlDispatchException () Unknown ntdll.dll!KiUserExceptionDispatch () Unknown msvcp110d.dll!std::basic_ostream >::~basic_ostream >() Line 87 C++ formulascoringtests.exe!std::basic_ostringstream, std::allocator >::~basic_ostringstream() Line 543 C++ msvcr110d.dll!_CallSettingFrame() Line 51 Unknown msvcr110d.dll!__FrameUnwindToState(unsigned __int64 * pRN=0x00000000009bdcf8, _xDISPATCHER_CONTEXT * pDC=0x00000000009bdec0, const _s_FuncInfo * pFuncInfo=0x0000000142ac4698, int targetState=-1) Line 1064 C++ msvcr110d.dll!__FrameUnwindToEmptyState(unsigned __int64 * pRN=0x00000000009bdde0, _xDISPATCHER_CONTEXT * pDC=0x00000000009bdec0, const _s_FuncInfo * pFuncInfo=0x0000000142ac4698) Line 158 C++ msvcr110d.dll!__InternalCxxFrameHandler(EHExceptionRecord * pExcept=0x00000000009bf1b0, unsigned __int64 * pRN=0x00000000009bdde0, _CONTEXT * pContext=0x00000000009be6c0, _xDISPATCHER_CONTEXT * pDC=0x00000000009bdec0, const _s_FuncInfo * pFuncInfo=0x0000000142ac4698, int CatchDepth=0, unsigned __int64 * pMarkerRN=0x0000000000000000, unsigned char recursive='\0') Line 393 C++ msvcr110d.dll!__CxxFrameHandler3(EHExceptionRecord * pExcept=0x00000000009bf1b0, unsigned __int64 RN=10220368, _CONTEXT * pContext=0x00000000009be6c0, _xDISPATCHER_CONTEXT * pDC=0x00000000009bdec0) Line 193 C++ ntdll.dll!RtlpExecuteHandlerForUnwind () Unknown ntdll.dll!RtlUnwindEx () Unknown kernel32.dll!000000007785050e() Unknown msvcr110d.dll!__C_specific_handler(_EXCEPTION_RECORD * ExceptionRecord=0x00000000009bf1b0, void * EstablisherFrame=0x00000000009bf710, _CONTEXT * ContextRecord=0x00000000009becc0, _DISPATCHER_CONTEXT * DispatcherContext=0x00000000009be670) Line 212 C ntdll.dll!RtlpExecuteHandlerForException () Unknown ntdll.dll!RtlDispatchException () Unknown ntdll.dll!KiUserExceptionDispatch () Unknown msvcp110d.dll!std::basic_streambuf >::setg(char * _First=0x0000000000000000, char * _Next=0x0000000000000000, char * _Last=0x0000000000000000) Line 247 C++ formulascoringtests.exe!std::basic_stringbuf, std::allocator >::_Tidy() Line 348 C++ formulascoringtests.exe!std::basic_stringbuf, std::allocator >::~basic_stringbuf() Line 77 C++ formulascoringtests.exe!std::basic_ostringstream, std::allocator >::~basic_ostringstream() Line 544 C++ formulascoringtests.exe!std::basic_ostringstream,class std::allocator >::`vbase destructor'(void) C++ formulascoringtests.exe!boost::optional_detail::optional_base::destroy_impl(boost::mpl::bool_<0>={...}) Line 479 C++ formulascoringtests.exe!boost::optional_detail::optional_base::destroy() Line 440 C++ formulascoringtests.exe!boost::optional_detail::optional_base::~optional_base() Line 268 C++ formulascoringtests.exe!boost::optional::~optional() Line 567 C++ formulascoringtests.exe!bdal::logging::LoggerStream::~LoggerStream() Line 221 C++ formulascoringtests.exe!boost_optional_detail::boost_optional_detail::() Line 45 C++ formulascoringtests.exe!testing::internal::HandleSehExceptionsInMethodIfSupported(testing::Test * object=0x0000000000bdb590, void (void) * method=0x000000013fe6bb30, const char * location=0x000000014249fda8) Line 2063 C++ formulascoringtests.exe!testing::internal::HandleExceptionsInMethodIfSupported(testing::Test * object=0x0000000000bdb590, void (void) * method=0x000000013fe6bb30, const char * location=0x000000014249fda8) Line 2114 C++ formulascoringtests.exe!testing::Test::Run() Line 2157 C++ formulascoringtests.exe!testing::TestInfo::Run() Line 2330 C++ formulascoringtests.exe!testing::TestCase::Run() Line 2445 C++ formulascoringtests.exe!testing::internal::UnitTestImpl::RunAllTests() Line 4316 C++ formulascoringtests.exe!testing::internal::HandleSehExceptionsInMethodIfSupported(testing::internal::UnitTestImpl * object=0x0000000000baaee0, bool (void) * method=0x000000013fe4b690, const char * location=0x000000014249e7c8) Line 2063 C++ formulascoringtests.exe!testing::internal::HandleExceptionsInMethodIfSupported(testing::internal::UnitTestImpl * object=0x0000000000baaee0, bool (void) * method=0x000000013fe4b690, const char * location=0x000000014249e7c8) Line 2114 C++ formulascoringtests.exe!testing::UnitTest::Run() Line 3929 C++ formulascoringtests.exe!RUN_ALL_TESTS() Line 2289 C++ formulascoringtests.exe!main(int argc=1, char * * argv=0x0000000000baa7e0) Line 38 C++ formulascoringtests.exe!__tmainCRTStartup() Line 536 C formulascoringtests.exe!mainCRTStartup() Line 377 C kernel32.dll!00000000778359ed() Unknown ntdll.dll!RtlUserThreadStart () Unknown
0 Kudos
Sukruth_H_Intel
Employee
1,984 Views

Hi,

     Can you please compile using "/Qcheck-pointers" option to check if there are any bounds violation? You can find more details about this option here :-

https://software.intel.com/sites/products/documentation/doclib/iss/2013/compiler/cpp-lin/GUID-7E8868FF-51FD-4BAD-9E97-1CE6B96D50B6.htm ;

Please be noted that this option has some overhead!!

Regards,

Sukruth H V 

0 Kudos
Wiebke_T_
Beginner
1,984 Views

I don't see any difference when compiling with /Qcheck-pointers. I don't get any "Debug Assertion Failed!" message during runtime. Actually, the behavior does not change at all. (Which I get when I deliberately insert a line that accesses out of bounds, so the compiler option is definitely active.)

Interestingly, calls into the other VS2012-compiled libraries work: The problematic library is a (lazy) logging library, and all unit tests work correctly if nothing is logged. I will try to drill down when exactly this behavior occurs.

 

 

0 Kudos
Bernard
Valued Contributor I
1,984 Views

@Wiebke T

Can you upload call stack as text file?

0 Kudos
Bernard
Valued Contributor I
1,984 Views

 

@Wiebke

In your case running your program under windbg could be more helpful in finding access violation exception.Debugger will break-in on av occurrence.

It could be code related access violation or data related.

0 Kudos
Sukruth_H_Intel
Employee
1,984 Views

Hi,

      As stated /Qcheck-pointers would be helpful to detect the OOB overflows at the runtime. So i just wanted you to try this option to see if there are any OOB's.

It would be helpful to further investigate on this issue, if you can provide me a simple testcase.

Regards,

Sukruth H V

0 Kudos
Wiebke_T_
Beginner
1,984 Views

Dear all,I tried /Qcheck-pointers and it does NOT trigger when I run under debug. So there is no out of bounds or any other check assertion. (Also remember that the same call works flawlessly under gcc 4.8 and vc110). The behavior in debug configuration is similar to that in release configuration, just the places where the current line jumps after leaving said call differs.

The colleague who maintains the library is trying to find the root cause. He suspects it may have to do with how the icc treats temporaries.

0 Kudos
Wiebke_T_
Beginner
1,984 Views

This test reproduces the problem (thanks to my colleague Daniel for figuring this out):

//---------------------------------------------
#include <sstream>
#include "boost/optional.hpp"

void test()
{
  boost::optional<std::ostringstream> os_;
  os_ = boost::in_place();
  (*os_) << "Hu!" << std::flush;
  os_ = boost::none; // Crash here
}

int main()
{
  test();
}

 

It happens when this is compiled with the composer, it's not a VS2012 compatibility issue.

 

0 Kudos
Wiebke_T_
Beginner
1,984 Views

Can we change the title, please? This has nothing to do with Visual Studio...

0 Kudos
EGolu
Beginner
1,984 Views
Same issue here, started happening after I updated to XE SP1 Update 3. I use VS2013, the latest version. > msvcr120.dll!doexit(int code=0, int quick=0, int retcaller=0) Line 628 crt0dat.c onexitbegin_new = (_PVFV *) DecodePointer(__onexitbegin); __onexitbegin is not a valid pointer. I should also note that I use external libraries, and the issue only occurs with optimization enabled.
0 Kudos
Bernard
Valued Contributor I
1,984 Views

It looks like an issue is related to msvcr120.dll library.

>>>__onexitbegin is not a valid pointer>>>

Is this message thrown by msvcr120.dll library code?

0 Kudos
Bernard
Valued Contributor I
1,984 Views

@Evgeni

Did you encode __onexitbegin with EncodePointer() function?

http://msdn.microsoft.com/en-us/library/bb432242(v=vs.85).aspx

0 Kudos
Wiebke_T_
Beginner
1,984 Views

@Evgenii: I'm not sure this is the "same issue"...

@iliyapolak: Any feedback on the code snippet I posted?

 

0 Kudos
Bernard
Valued Contributor I
1,984 Views

@Wiebke

Today I will try to reproduce your issue.

test-case from the post #13

0 Kudos
Wiebke_T_
Beginner
1,984 Views

@Iliyapolak: Thank you! Didn't mean to hurry you up, just wanting to make sure the thread doesn't go astray to other (even if related) issues :)

 

0 Kudos
Bernard
Valued Contributor I
1,779 Views

@Wiebke

My test case compiles fine either in debug build or in release build.

1>------ Build started: Project: IDZ_test3, Configuration: Release Win32 ------
1>  stdafx.cpp
1>  IDZ_test113.cpp
1>  xilink: executing 'link'
1>  IDZ_test3.vcxproj -> c:\users\bernard\documents\visual studio 2013\Projects\IDZ_test3\Release\IDZ_test113.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

 

Can you post your compiler settings?

 

0 Kudos
Reply