Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7054275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:36:25+00:00 2026-05-28T03:36:25+00:00

I encounter really weird problem on which I stuck. I am working on some

  • 0

I encounter really weird problem on which I stuck.

I am working on some class library which connects to webservices. The library is used by desktop applications.

In the code I have now:

Int32 errorCode32 = errorCode;
Int32 errorTimeout = 300;

if (errorCode32.Equals(errorTimeout) == false)
{
    System.Console.Out.WriteLine("aaa");
    return;
}

where errorCode equals to 300. So at the first glance it is visible, that if errorCode == 300 than the code inside the if statement should not be executed because it is defined to be executed only when errorCode is not equal to 300.

Until now everything is clear, but now the whole fun starts.

Application is working and the method with above code snippet is executed. errorCode is equal to 300, that is expected result is that the application will not execute any code inside if statement because whole statement is false. But in reality application goes inside “if” and immediately skips to the “return” statement. System.Console.Out… is never executed. If I will replace clean “return” statement with “throw new SomeException()”

Int32 errorCode32 = errorCode;
Int32 errorTimeout = 300;

if (errorCode32.Equals(errorTimeout) == false)
{
    System.Console.Out.WriteLine("aaa");
    throw new SomeException();
}

I will get the same result. Application goes into if statement (note: [errorCode32.Equals(errorTimeout) == false] is false in my case), don’t execute Console.Out… but throws SomeException.

I rebuilded everything several times, deleted all binaries, I even deleted whole project from disk and retrieved it again from repository to clean folder.

I was so confused that I even disassembled the code to see what happens (even if I am not an expert in assembler). But results are strange for me.

Disassembled code follows:

    50:                 Int32 errorCode32 = errorCode;
000000e5  mov         eax,dword ptr [ebp-50h] 
000000e8  mov         dword ptr [ebp-54h],eax 
    51:                 Int32 errorTimeout = 300;
000000eb  mov         dword ptr [ebp-58h],12Ch 
    52: 
    53:                 if (errorCode32.Equals(errorTimeout) == false)
000000f2  lea         ecx,[ebp-54h] 
000000f5  mov         edx,dword ptr [ebp-58h] 
000000f8  call        699EB198 
000000fd  mov         dword ptr [ebp-68h],eax 
00000100  movzx       eax,byte ptr [ebp-68h] 
00000104  mov         dword ptr [ebp-48h],eax 
00000107  cmp         dword ptr [ebp-48h],0 
0000010b  jne         00000134 
    54:                 {
0000010d  nop              
    55:                     System.Console.Out.WriteLine("aaa");
0000010e  call        69538768 
00000113  mov         dword ptr [ebp+FFFFFF7Ch],eax 
00000119  mov         edx,dword ptr ds:[0302CE30h] 
0000011f  mov         ecx,dword ptr [ebp+FFFFFF7Ch] 
00000125  mov         eax,dword ptr [ecx] 
00000127  call        dword ptr [eax+000000D8h] 
0000012d  nop              
    56:                     return;
0000012e  nop              
0000012f  jmp         00000287 
00000134  mov         eax,dword ptr ds:[0302CE34h] 
0000013a  mov         dword ptr [ebp-6Ch],eax 
0000013d  mov         edx,5 
00000142  mov         ecx,6EDE3FBEh 
00000147  call        FA68D488 
0000014c  mov         dword ptr [ebp-70h],eax 
    57:                 }

when I am debugging instructions I can understand what happens until the line:

00000104  mov         dword ptr [ebp-48h],eax

I expect that value stored in eax will be copied to location “dword ptr [ebp-48h]” and application wiil go to next line (00000107). But this doesn’t happen. When I am trying to step over line 00000104, application immediately jumps to line

00000134  mov         eax,dword ptr ds:[0302CE34h]

I cannot understand what happens here. I tried to search over internet but I couldn’t find anything useful. Does anybody have any suggestions what could be the reason of the problem or how to solve that?


Edit

I forgot to put information that I am using Visual Studio 2008 and compiling into .NET 3.5.
All updates are installed.


Edit

Entire method in C#

        private void nativeDocumentServiceWrapper_PostInvokeEvents(object sender, WebServiceInvokeEventArgs e)
        {
            Exception exception = e.Exception;
            if (exception == null)
            {
                _invokeRetries = 0;
                return;
            }

            string errorCodeString = ErrorHandler.GetErrorCodeString(exception);
            int errorCode;
            if (int.TryParse(errorCodeString, out errorCode))
            {
                e.Exception = new VaultException(errorCode, exception);
            }

            Int32 errorCode32 = errorCode;
            Int32 errorTimeout = 300;

            if (errorCode32.Equals(errorTimeout) == false)
            {
                System.Console.Out.WriteLine("aaa");
                return;
            }

            Trace.TraceWarning("Invoke failed (count: {4}) {0}.{1} #{2} error '{3}'", _moduleName, e.MethodName, _id, errorCodeString, _invokeRetries + 1);

            if (_invokeRetries > 0)
            {
                //int errorCode;
                if (int.TryParse(errorCodeString, out errorCode))
                {
                    //throw new VaultException(errorCode, exception);
                    e.Exception = new VaultException(errorCode, exception);
                }
                return;
            }

            e.Exception = null;

            // we ran into error 300 or 319
            // the solution is to log in again and re-run the command

            tryReloginAndInvokeVaultMethodAgain(e);
        }

and disassembled:

    34:             private void nativeDocumentServiceWrapper_PostInvokeEvents(object sender, WebServiceInvokeEventArgs e)
    35:             {
00000000  push        ebp  
00000001  mov         ebp,esp 
00000003  push        edi  
00000004  push        esi  
00000005  push        ebx  
00000006  sub         esp,84h 
0000000c  mov         esi,ecx 
0000000e  lea         edi,[ebp-54h] 
00000011  mov         ecx,12h 
00000016  xor         eax,eax 
00000018  rep stos    dword ptr es:[edi] 
0000001a  mov         ecx,esi 
0000001c  xor         eax,eax 
0000001e  mov         dword ptr [ebp-1Ch],eax 
00000021  mov         dword ptr [ebp-3Ch],ecx 
00000024  mov         dword ptr [ebp-40h],edx 
00000027  cmp         dword ptr ds:[01AD2DD8h],0 
0000002e  je          00000035 
00000030  call        6AB8A719 
00000035  mov         dword ptr [ebp-48h],0 
0000003c  xor         edx,edx 
0000003e  mov         dword ptr [ebp-5Ch],edx 
00000041  xor         edx,edx 
00000043  mov         dword ptr [ebp-44h],edx 
00000046  xor         edx,edx 
00000048  mov         dword ptr [ebp-4Ch],edx 
0000004b  xor         edx,edx 
0000004d  mov         dword ptr [ebp-58h],edx 
00000050  nop              
    36:                 Exception exception = e.Exception;
00000051  mov         eax,dword ptr [ebp+8] 
00000054  mov         eax,dword ptr [eax+4] 
00000057  mov         dword ptr [ebp-44h],eax 
    37:                 if (exception == null)
0000005a  cmp         dword ptr [ebp-44h],0 
0000005e  setne       al   
00000061  movzx       eax,al 
00000064  mov         dword ptr [ebp-48h],eax 
00000067  cmp         dword ptr [ebp-48h],0 
0000006b  jne         0000007F 
    38:                 {
0000006d  nop              
    39:                     _invokeRetries = 0;
0000006e  mov         eax,dword ptr [ebp-3Ch] 
00000071  xor         edx,edx 
00000073  mov         dword ptr [eax+00000088h],edx 
    40:                     return;
00000079  nop              
0000007a  jmp         00000287 
    41:                 }
    42: 
    43:                 string errorCodeString = ErrorHandler.GetErrorCodeString(exception);
0000007f  mov         ecx,dword ptr [ebp-44h] 
00000082  call        FF0827F0 
00000087  mov         dword ptr [ebp-60h],eax 
0000008a  mov         eax,dword ptr [ebp-60h] 
0000008d  mov         dword ptr [ebp-4Ch],eax 
    44:                 int errorCode;
    45:                 if (int.TryParse(errorCodeString, out errorCode))
00000090  lea         edx,[ebp-50h] 
00000093  mov         ecx,dword ptr [ebp-4Ch] 
00000096  call        694B44A8 
0000009b  mov         dword ptr [ebp-64h],eax 
0000009e  cmp         dword ptr [ebp-64h],0 
000000a2  sete        al   
000000a5  movzx       eax,al 
000000a8  mov         dword ptr [ebp-48h],eax 
000000ab  cmp         dword ptr [ebp-48h],0 
000000af  jne         000000E5 
    46:                 {
000000b1  nop              
    47:                     e.Exception = new VaultException(errorCode, exception);
000000b2  mov         ecx,5482E0Ch 
000000b7  call        FA68D364 
000000bc  mov         dword ptr [ebp+FFFFFF78h],eax 
000000c2  push        dword ptr [ebp-44h] 
000000c5  mov         edx,dword ptr [ebp-50h] 
000000c8  mov         ecx,dword ptr [ebp+FFFFFF78h] 
000000ce  call        FF07FCB0 
000000d3  mov         edx,dword ptr [ebp+8] 
000000d6  mov         eax,dword ptr [ebp+FFFFFF78h] 
000000dc  lea         edx,[edx+4] 
000000df  call        6A90E288 
    48:                 }
000000e4  nop              
    49: 
    50:                 Int32 errorCode32 = errorCode;
000000e5  mov         eax,dword ptr [ebp-50h] 
000000e8  mov         dword ptr [ebp-54h],eax 
    51:                 Int32 errorTimeout = 300;
000000eb  mov         dword ptr [ebp-58h],12Ch 
    52: 
    53:                 if (errorCode32.Equals(errorTimeout) == false)
000000f2  lea         ecx,[ebp-54h] 
000000f5  mov         edx,dword ptr [ebp-58h] 
000000f8  call        699EB198 
000000fd  mov         dword ptr [ebp-68h],eax 
00000100  movzx       eax,byte ptr [ebp-68h] 
00000104  mov         dword ptr [ebp-48h],eax 
00000107  cmp         dword ptr [ebp-48h],0 
0000010b  jne         00000134 
    54:                 {
0000010d  nop              
    55:                     System.Console.Out.WriteLine("aaa");
0000010e  call        69538768 
00000113  mov         dword ptr [ebp+FFFFFF7Ch],eax 
00000119  mov         edx,dword ptr ds:[0302CE30h] 
0000011f  mov         ecx,dword ptr [ebp+FFFFFF7Ch] 
00000125  mov         eax,dword ptr [ecx] 
00000127  call        dword ptr [eax+000000D8h] 
0000012d  nop              
    56:                     return;
0000012e  nop              
0000012f  jmp         00000287 
00000134  mov         eax,dword ptr ds:[0302CE34h] 
0000013a  mov         dword ptr [ebp-6Ch],eax 
0000013d  mov         edx,5 
00000142  mov         ecx,6EDE3FBEh 
00000147  call        FA68D488 
0000014c  mov         dword ptr [ebp-70h],eax 
    57:                 }
    58: 
    59:                 Trace.TraceWarning("Invoke failed (count: {4}) {0}.{1} #{2} error '{3}'", _moduleName, e.MethodName, _id, errorCodeString, _invokeRetries + 1);
0000014f  mov         eax,dword ptr [ebp-70h] 
00000152  mov         dword ptr [ebp-5Ch],eax 
00000155  mov         eax,dword ptr [ebp-3Ch] 
00000158  push        dword ptr [eax+00000080h] 
0000015e  mov         ecx,dword ptr [ebp-5Ch] 
00000161  xor         edx,edx 
00000163  call        6A914654 
00000168  mov         eax,dword ptr [ebp+8] 
0000016b  push        dword ptr [eax+8] 
0000016e  mov         ecx,dword ptr [ebp-5Ch] 
00000171  mov         edx,1 
00000176  call        6A914654 
0000017b  mov         ecx,6F052DA0h 
00000180  call        FA68D364 
00000185  mov         dword ptr [ebp-74h],eax 
00000188  mov         eax,dword ptr [ebp-5Ch] 
0000018b  mov         dword ptr [ebp+FFFFFF74h],eax 
00000191  mov         eax,dword ptr [ebp-3Ch] 
00000194  mov         eax,dword ptr [eax+00000084h] 
0000019a  mov         edx,dword ptr [ebp-74h] 
0000019d  mov         dword ptr [edx+4],eax 
000001a0  mov         eax,dword ptr [ebp-74h] 
000001a3  push        eax  
000001a4  mov         ecx,dword ptr [ebp+FFFFFF74h] 
000001aa  mov         edx,2 
000001af  call        6A914654 
000001b4  push        dword ptr [ebp-4Ch] 
000001b7  mov         ecx,dword ptr [ebp-5Ch] 
000001ba  mov         edx,3 
000001bf  call        6A914654 
000001c4  mov         ecx,6F052DA0h 
000001c9  call        FA68D364 
000001ce  mov         dword ptr [ebp-78h],eax 
000001d1  mov         eax,dword ptr [ebp-5Ch] 
000001d4  mov         dword ptr [ebp+FFFFFF70h],eax 
000001da  mov         eax,dword ptr [ebp-3Ch] 
000001dd  mov         eax,dword ptr [eax+00000088h] 
000001e3  inc         eax  
000001e4  mov         edx,dword ptr [ebp-78h] 
000001e7  mov         dword ptr [edx+4],eax 
000001ea  mov         eax,dword ptr [ebp-78h] 
000001ed  push        eax  
000001ee  mov         ecx,dword ptr [ebp+FFFFFF70h] 
000001f4  mov         edx,4 
000001f9  call        6A914654 
000001fe  mov         edx,dword ptr [ebp-5Ch] 
00000201  mov         ecx,dword ptr [ebp-6Ch] 
00000204  call        69039D88 
00000209  nop              
    60: 
    61:                 if (_invokeRetries > 0)
0000020a  mov         eax,dword ptr [ebp-3Ch] 
0000020d  cmp         dword ptr [eax+00000088h],0 
00000214  setle       al   
00000217  movzx       eax,al 
0000021a  mov         dword ptr [ebp-48h],eax 
0000021d  cmp         dword ptr [ebp-48h],0 
00000221  jne         00000273 
    62:                 {
00000223  nop              
    63:                     //int errorCode;
    64:                     if (int.TryParse(errorCodeString, out errorCode))
00000224  lea         edx,[ebp-50h] 
00000227  mov         ecx,dword ptr [ebp-4Ch] 
0000022a  call        694B44A8 
0000022f  mov         dword ptr [ebp-7Ch],eax 
00000232  cmp         dword ptr [ebp-7Ch],0 
00000236  sete        al   
00000239  movzx       eax,al 
0000023c  mov         dword ptr [ebp-48h],eax 
0000023f  cmp         dword ptr [ebp-48h],0 
00000243  jne         00000270 
    65:                     {
00000245  nop              
    66:                         //throw new VaultException(errorCode, exception);
    67:                         e.Exception = new VaultException(errorCode, exception);
00000246  mov         ecx,5482E0Ch 
0000024b  call        FA68D364 
00000250  mov         dword ptr [ebp-80h],eax 
00000253  push        dword ptr [ebp-44h] 
00000256  mov         edx,dword ptr [ebp-50h] 
00000259  mov         ecx,dword ptr [ebp-80h] 
0000025c  call        FF07FCB0 
00000261  mov         edx,dword ptr [ebp+8] 
00000264  mov         eax,dword ptr [ebp-80h] 
00000267  lea         edx,[edx+4] 
0000026a  call        6A90E288 
    68:                     }
0000026f  nop              
    69:                     return;
00000270  nop              
00000271  jmp         00000287 
    70:                 }
    71: 
    72:                 e.Exception = null;
00000273  mov         eax,dword ptr [ebp+8] 
00000276  xor         edx,edx 
00000278  mov         dword ptr [eax+4],edx 
    73: 
    74:                 // we ran into error 300 or 319
    75:                 // the solution is to log in again and re-run the command
    76: 
    77:                 tryReloginAndInvokeVaultMethodAgain(e);
0000027b  mov         edx,dword ptr [ebp+8] 
0000027e  mov         ecx,dword ptr [ebp-3Ch] 
00000281  call        FF0876C0 
00000286  nop              
    78:             }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:36:25+00:00Added an answer on May 28, 2026 at 3:36 am

    I spent more time investigating the problem and I have some conclusions which I would like to share, even if it means that I must to admit that I made several false assumptions and I was not able to get a big picture of whole behavior.

    First: the code which I presented was intended to handle some particular problem when using some third party library. The undocumented behavior of those library was that in some situation it throws exception on some conditions. Original problem comes from the fact, that library throwed exception even if we “handled” error situation

    Second: when debugging I found following situation:

    1    if (someVariable)
    2    {
    3        someCode();
    4        someOtherCode();
    5        throw someExceptionPassedFromTheThirdPartyLibrary;
    6    }
    7    somethingElse();
    

    debugger stopped at line 1, someVariable is false, step over, debugger is waiting at line 5. And here I made a first false assumption – that is that my exception is thrown from here.

    Third: I started to experiment. “someVariable” was always false, but sometimes debugger skipped from line 1 to 7 and sometimes from 1 to 5. I decided to use disassembler.

    Fourth: I couldn’t understand behavior of disassembled code and it fixed my mind on idea, that if statement behaves incorrectly. Additionally I found article “http://stackoverflow.com/questions/6054987/if-statement-appears-to-be-evaluating-even-when-condition-evaluates-to-false” [confirmed JIT bug] which didn’t helped me this time.

    Ok I think that after some additional background it is time to explain what really happened in my code.

    In general in my situation “if” statement behaved correctly. I understood that when I learned a little bit more regarding assembler and moder processor architecture.

        53:                 if (errorCode32.Equals(errorTimeout) == false)
    000000f2  lea         ecx,[ebp-54h] 
    000000f5  mov         edx,dword ptr [ebp-58h] 
    000000f8  call        699EB198 
    000000fd  mov         dword ptr [ebp-68h],eax 
    00000100  movzx       eax,byte ptr [ebp-68h] 
    00000104  mov         dword ptr [ebp-48h],eax 
    00000107  cmp         dword ptr [ebp-48h],0 
    0000010b  jne         00000134 
        54:                 {
    0000010d  nop              
        55:                     System.Console.Out.WriteLine("aaa");
    0000010e  call        69538768 
    00000113  mov         dword ptr [ebp+FFFFFF7Ch],eax 
    00000119  mov         edx,dword ptr ds:[0302CE30h] 
    0000011f  mov         ecx,dword ptr [ebp+FFFFFF7Ch] 
    00000125  mov         eax,dword ptr [ecx] 
    00000127  call        dword ptr [eax+000000D8h] 
    0000012d  nop              
        56:                     return;
    0000012e  nop              
    0000012f  jmp         00000287 
    00000134  mov         eax,dword ptr ds:[0302CE34h] 
    0000013a  mov         dword ptr [ebp-6Ch],eax 
    0000013d  mov         edx,5 
    00000142  mov         ecx,6EDE3FBEh 
    00000147  call        FA68D488 
    0000014c  mov         dword ptr [ebp-70h],eax 
        57:                 }
    

    Execution of instructions at offsets 00000104-0000010b was optimized by processor architecture (perhaps jump predicting takes place, or some other core processor optimizations). So instead of calling three instructions, processor executed everything in one step. Because values which should be compared in 00000107 were not equal, so processor jumped to 00000134. At this point I couldn’t understand what actually happens here, so I assumed that it just executes “return” instruction. The truth is simple – “return from if” instruction is not at 00000134 as I though, but instruction arealier – at 0000012f and this is just simple unconditional jump.

    When I understood this I knew that this code behaves corretly. So I moved again to C# and I found something which made me really ashamed. Because when I debugged the code once again I found that it behaves this way:

    1    if (someVariable)
    2    {
    3        someCode();
    4        someOtherCode();
    5        throw someExceptionPassedFromTheThirdPartyLibrary;
    6    }
    7    somethingElse();
    

    breakpoint at 1, F10
    current line indicator at 5, press F10
    current line indicator at 7, press F10… and so on.

    So I understood that the debugger steps inside last “if” instruction, but doesn’t execute that. It is a bug – but not in “if” handling, and only in VS debugger. Additionally the bug is not critical since it is actually just presentation and doesn’t have any influence on the debugged code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What do you do when you encounter a programming problem that is really hard
This is a problem I encounter frequently in working with more complex systems and
EDIT: Here's the video showing the problem: www.youtube.com/watch?v=5ZZsuMH5T9k I'm really stuck here :/ --
This is the second time that I have this really weird problem with WCF
I encountered today a weird bug with an app I'm working on. The problem
I frequently encounter some definitions for Win32API structures (but not limited to it) that
I frequently encounter this situation in my VB6 applications Private Sub DoSomething On Error
I use AppEngine JRuby on Rails (SDK version 1.3.3.1) - a problem I encounter
I'm having a really weird issue with a background worker in one of my
every time i encounter this word i wonder what it really means. eg an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.