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

VS2010 - Breakpoint generates "Illegal Instruction" exception

Bernhard_Zellner
Beginner
2,790 Views

I have a small test project for boost serialize.

When running the release version of the test project the program runs till the end.

When setting a breakpoint in the release version in BoostSerialize.cpp line 332 then i get

"Unhandled exception at 0x00364645 in BoostSerialize.exe: 0xC000001D: Illegal Instruction."

I am using VS2010, Intel Compiler 14.0 SP1 and boost 1.54, static linked. boost is compiled with the following settings:
using intel : 14.0 : $(intel-compiler-14)/bin/ia32/icl.exe : <compatibility>vc10 <cxxflags>"/Qstd=c++11  /Qipo /Qdiag-disable:2586 /D_CRT_SECURE_NO_WARNINGS" ;

The test project is attached as zip file.

The problem can be reproduced on different PC's (Win7x64 pro, i7 and Xeon)

Bernhard

0 Kudos
51 Replies
SergeyKostrov
Valued Contributor II
1,669 Views
Please verify what Intel instruction set was selected to build the test-case. For example, It is possible that AVX instruction set was selected by default but your CPU supports SSE4.1 instruction set.
0 Kudos
Bernhard_Zellner
Beginner
1,669 Views

There is no specific instructionset selected. The exception is only thrown when setting a breakpoint in line 332 of BoostSerialize.cpp.

Compile settings:

/I"C:\Libs\boost\boost_1_54_0\include" /Zi /nologo /W3 /O3 /Qipo /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /EHsc /GS /Zc:wchar_t /Zc:forScope /Fp"Release\BoostSerialize.pch" /Fa"Release\" /Fo"Release\" /Fd"Release\vc100.pdb" /Gd

Linker settings:

/OUT:"C:\project\spielwiese\BoostSerialize - Copy\Release\BoostSerialize.exe" /NOLOGO /LIBPATH:"C:\Libs\boost\boost_1_54_0\lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Release\BoostSerialize.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\project\spielwiese\BoostSerialize - Copy\Release\BoostSerialize.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86

0 Kudos
SergeyKostrov
Valued Contributor II
1,669 Views
When in the Debugger could you take a look at what instruction causes 0xC000001D exception?
0 Kudos
Bernard
Valued Contributor I
1,669 Views

It is usually signaled by CPU as a invalid opcode exception(can be related perhaps to prefixes).Could be caused by compiler while emmiting unsupported instruction.As Sergey advised please look at assembly code.

0 Kudos
SergeyKostrov
Valued Contributor II
1,669 Views
I verified project settings and detected one small issue: In Release Configuration a Linker Setting 'Generate Debug Info' is set to 'Yes' ( Actually, it is OK ). My questions are: What instruction set do you need to support? AVX2? AVX? SSE4.1? Or something else?
0 Kudos
Bernhard_Zellner
Beginner
1,669 Views

Sorry for the long delay - i was some days not in the office.

When running the code on my desktop pc (Win7x64, Intel Xeon E5-1607) i got the following:

After selecting "Go to disassembly" i got the following message box:

and the assembler code:

Running the same per remote debugger on Win7x86 Embedded, Celeron Dual-Core T3100, i got the same result.

When running the program without any breakpoint everything works correct.

 

0 Kudos
SergeyKostrov
Valued Contributor II
1,669 Views
Bernhard, Could you attach these two pictures as external files ( Not as Media files )?
0 Kudos
Bernhard_Zellner
Beginner
1,669 Views

This is the assembler code when running on Intel Xeon E5-1607

   325:     save_data_binary(data_container,filename.c_str());
00B5462B  add         esp,0FFFFFFF0h  
00B5462E  lea         edx,[filename]  
00B54634  cmp         dword ptr [ebp-8Ch],10h  
00B5463B  lea         eax,[data_container]  
00B54641  db          0fh  
00B54642  inc         ebx  
   330:
   331:     // restore the data_container
   332:     test_data_container restored_data_container;
00B54643  xchg        eax,ebp  <== Breakpoint
00B54644  pushad  
00B54645  db          ffh             <== Instructionpointer
00B54646  db          ffh  
00B54647  dec         dword ptr [ecx+54892404h]  
00B5464D  and         al,4  
00B5464F  call        save_data_binary (0B610E0h)  
00B54654  add         esp,10h  
   326:     save_data_string(data_container,filename.c_str());
00B54657  add         esp,0FFFFFFF0h  
00B5465A  lea         edx,[filename]  
00B54660  cmp         dword ptr [ebp-8Ch],10h  
00B54667  lea         eax,[data_container]  
00B5466D  cmovae      edx,dword ptr [filename]  
00B54674  mov         dword ptr [esp],eax  
00B54677  mov         dword ptr [esp+4],edx  
00B5467B  call        save_data_string (0B60050h) 
 

0 Kudos
Bernard
Valued Contributor I
1,669 Views

>>>00B54645  db          ffh             <== Instructionpointer
00B54646  db          ffh  >>>

This looks like not properly disassembled code.Also pay attention to this machine code line >>>00B54647  dec         dword ptr [ecx+54892404h]>>> the offset looks a way to big.It seems that exception is thrown when the breakpoint is set.Do you know what breakpoint it is?I mean int 0x3 or writing to debug registers.

I suppose that compiler might have inserted two byte opcode of int 0x3 instruction.That's mean 0xCD03 instead of 0xCC.

Can you post machine code at this location?:00B54643 

0 Kudos
Bernard
Valued Contributor I
1,669 Views

I am thinking how to see what opcode of breakpoint was emmited by VS debugger.

0 Kudos
SergeyKostrov
Valued Contributor II
1,669 Views
>>00B54646 db ffh >>> >> >>This looks like not properly disassembled code... Actually Yes and No since I had similar cases, that is, Illegal Instruction exception, on a system with Pentium 4 processor when by mistake I tried to execute an application compiled with support of AVX instructions. At the same time, Visual Studio 2008 really couldn't properly display disassembled codes since that version was released many years ago before AVX was released. Possible reason is as follows: There is an inconsistency related to codes generation between of your modules ( for example AVX ) and Boost binary modules ( located in C:\Libs\boost\boost_1_54_0\... folder, or so ), for example AVX2
0 Kudos
SergeyKostrov
Valued Contributor II
1,669 Views
Also, take into account that, for example: #pragma intel optimization_parameter target_arch=AVX or #pragma intel optimization_parameter target_arch=AVX2 could be used in different source code files even if the main application is compiled with default architecture defined in a VS project as SSE or IA-32.
0 Kudos
Bernhard_Zellner
Beginner
1,669 Views

I deleted all breakpoints and started the program with F10 in VS2010. Then i attach with windgb to the process. Windbg shows the following assembler code:

00c745d7 83c4f0          add     esp,0FFFFFFF0h
00c745da 83fa10          cmp     edx,10h
00c745dd 8d9560ffffff    lea     edx,[ebp-0A0h]
00c745e3 0f439560ffffff  cmovae  edx,dword ptr [ebp-0A0h]
00c745ea 8d85c0fdffff    lea     eax,[ebp-240h]
00c745f0 890424          mov     dword ptr [esp],eax
00c745f3 89542404        mov     dword ptr [esp+4],edx
00c745f7 e8c4e30000      call    BoostSerialize!save_data_text (00c829c0)
00c745fc 83c410          add     esp,10h
00c745ff 83c4f0          add     esp,0FFFFFFF0h
00c74602 8d9560ffffff    lea     edx,[ebp-0A0h]
00c74608 83bd74ffffff10  cmp     dword ptr [ebp-8Ch],10h
00c7460f 8d85c0fdffff    lea     eax,[ebp-240h]
00c74615 0f439560ffffff  cmovae  edx,dword ptr [ebp-0A0h]
00c7461c 890424          mov     dword ptr [esp],eax
00c7461f 89542404        mov     dword ptr [esp+4],edx
00c74623 e888d00000      call    BoostSerialize!save_data_xml (00c816b0)
00c74628 83c410          add     esp,10h
00c7462b 83c4f0          add     esp,0FFFFFFF0h
00c7462e 8d9560ffffff    lea     edx,[ebp-0A0h]
00c74634 83bd74ffffff10  cmp     dword ptr [ebp-8Ch],10h
00c7463b 8d85c0fdffff    lea     eax,[ebp-240h]
00c74641 0f439560ffffff  cmovae  edx,dword ptr [ebp-0A0h]
00c74648 890424          mov     dword ptr [esp],eax
00c7464b 89542404        mov     dword ptr [esp+4],edx
00c7464f e88cca0000      call    BoostSerialize!save_data_binary (00c810e0)
00c74654 83c410          add     esp,10h
00c74657 83c4f0          add     esp,0FFFFFFF0h
00c7465a 8d9560ffffff    lea     edx,[ebp-0A0h]
00c74660 83bd74ffffff10  cmp     dword ptr [ebp-8Ch],10h
00c74667 8d85c0fdffff    lea     eax,[ebp-240h]
00c7466d 0f439560ffffff  cmovae  edx,dword ptr [ebp-0A0h]
00c74674 890424          mov     dword ptr [esp],eax
00c74677 89542404        mov     dword ptr [esp+4],edx
00c7467b e8d0b90000      call    BoostSerialize!save_data_string (00c80050)

after setting the breakpoint at line 332 within VS2010 windbg shows the following assembler code:

00c745d7 83c4f0          add     esp,0FFFFFFF0h
00c745da 83fa10          cmp     edx,10h
00c745dd 8d9560ffffff    lea     edx,[ebp-0A0h]
00c745e3 0f439560ffffff  cmovae  edx,dword ptr [ebp-0A0h]
00c745ea 8d85c0fdffff    lea     eax,[ebp-240h]
00c745f0 890424          mov     dword ptr [esp],eax
00c745f3 89542404        mov     dword ptr [esp+4],edx
00c745f7 e8c4e30000      call    BoostSerialize!save_data_text (00c829c0)
00c745fc 83c410          add     esp,10h
00c745ff 83c4f0          add     esp,0FFFFFFF0h
00c74602 8d9560ffffff    lea     edx,[ebp-0A0h]
00c74608 83bd74ffffff10  cmp     dword ptr [ebp-8Ch],10h
00c7460f 8d85c0fdffff    lea     eax,[ebp-240h]
00c74615 0f439560ffffff  cmovae  edx,dword ptr [ebp-0A0h]
00c7461c 890424          mov     dword ptr [esp],eax
00c7461f 89542404        mov     dword ptr [esp+4],edx
00c74623 e888d00000      call    BoostSerialize!save_data_xml (00c816b0)
00c74628 83c410          add     esp,10h
00c7462b 83c4f0          add     esp,0FFFFFFF0h
00c7462e 8d9560ffffff    lea     edx,[ebp-0A0h]
00c74634 83bd74ffffff10  cmp     dword ptr [ebp-8Ch],10h
00c7463b 8d85c0fdffff    lea     eax,[ebp-240h]
00c74641 0f43cc          cmovae  ecx,esp
00c74644 60              pushad
00c74645 ff              ???
00c74646 ff              ???

00c74647 ff8904248954    dec     dword ptr [ecx+54892404h]
00c7464d 2404            and     al,4
00c7464f e88cca0000      call    BoostSerialize!save_data_binary (00c810e0)
00c74654 83c410          add     esp,10h
00c74657 83c4f0          add     esp,0FFFFFFF0h
00c7465a 8d9560ffffff    lea     edx,[ebp-0A0h]
00c74660 83bd74ffffff10  cmp     dword ptr [ebp-8Ch],10h
00c74667 8d85c0fdffff    lea     eax,[ebp-240h]
00c7466d 0f439560ffffff  cmovae  edx,dword ptr [ebp-0A0h]
00c74674 890424          mov     dword ptr [esp],eax
00c74677 89542404        mov     dword ptr [esp+4],edx
00c7467b e8d0b90000      call    BoostSerialize!save_data_string (00c80050)

Now i see that VS2010 debugger is setting the breakpoint (int3 == 0xcc) at a complete wrong position.

But who is responsible for this behaviour? The debugger of VS2010 or the intel compiler (pdb files?) ?

@Sergey

Thanks to your hint.

I will check if #pragma intel optimization_parameter target_arch is used.

0 Kudos
Bernhard_Zellner
Beginner
1,669 Views

there is no #pragma intel in my sources of boost 1.54

0 Kudos
SergeyKostrov
Valued Contributor II
1,669 Views
>>...boost 1.54... Here is another tip. Let's say your test application uses some Boost DLLs. Then, I would used MS Depends to verify exact names for these DLLs and then I would investigate how they are built and what Intel architectures are used. Also, If that magic Illegal instruction is located in the executable you've built then it looks like there is an issue on your side, or If that magic Illegal instruction is located in a Boost DLL, or a Boost static library (!), then it looks like there is an issue on Boost side You need to pinpoint that exactly.
0 Kudos
SergeyKostrov
Valued Contributor II
1,669 Views
>>...boost 1.54... Here is another tip. Let's say your test application uses some Boost DLLs. Then, I would used MS Depends to verify exact names for these DLLs and then I would investigate how they are built and what Intel architectures are used. Also, If that magic Illegal instruction is located in the executable you've built then it looks like there is an issue on your side, or If that magic Illegal instruction is located in a Boost DLL, or a Boost static library (!), then it looks like there is an issue on Boost side You need to pinpoint that exactly.
0 Kudos
Bernard
Valued Contributor I
1,669 Views

>>>Actually Yes and No since I had similar cases, that is, Illegal Instruction exception, on a system with Pentium 4 processor when by mistake I tried to execute an application compiled with support of AVX instructions>>>

In your case it was expected because CPU did not recognize the AVX instructions encoding hence invalid instruction exception was thrown. 

0 Kudos
Bernard
Valued Contributor I
1,669 Views

>>>00c74645 ff              ???
00c74646 ff              ??? >>>

Is this a location of the breakpoint?

 

0 Kudos
SergeyKostrov
Valued Contributor II
1,669 Views
>>...In your case it was expected because CPU did not recognize the AVX instructions... I've knew that and it was actually a tip to the user on what kind of issues to expect.
0 Kudos
Bernard
Valued Contributor I
1,436 Views

>>>Now i see that VS2010 debugger is setting the breakpoint (int3 == 0xcc) at a complete wrong position.

But who is responsible for this behaviour? The debugger of VS2010 or the intel compiler (pdb files?) ?>>>

At least you verified that used breakpoint is translated to 0xCC.Usually debugging thread opens process memory space and overwrites(inserts) the code with int3 opcodes.It could be also inserted by compiler when you have hardcoded breakpoints in your code.Possibly by using inline assembly or DebugBreak() function.

Take into account also Sergey's explanation it seems very logical.

0 Kudos
Reply