Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

VBC crash in Double to Decimal conversion #7148

Closed
MattGertz opened this Issue Dec 1, 2015 · 8 comments

Comments

Projects
None yet
6 participants
Contributor

MattGertz commented Dec 1, 2015

(MattGe posting from BHarry blog. Please verify in C# code as well.)

Hi Brian - I found a potential serious regression in VS2015 Update 1 when it comes to VB. It took me 2 hours of commenting out huge pieces of our codebase until I narrowed it down to one line of code that trips up vbc.exe. If I paste the rotation code directly into Sub Main, it works. If I make rotation local to CalculateDimensions, it works. But if I craft the code as follows, it causes a compiler error. All you have to do is make a VB 'Console Application'. Doesn't matter which version of .NET you target (4, 4.5, 4.5.1, 4.6, 4.6.1). I suspect others will run into something similar. It's like a needle in the haystack finding the culprit. Not sure who I should notify about this.

Module Module1
   Sub Main()
   End Sub
End Module

Public Class TestClass
   Private _rotation As Decimal
   Private Sub CalculateDimensions()
       _rotation *= 180 / Math.PI 'This line causes '"vbc.exe" exited with code -2146232797'
   End Sub
End Class

(MattGe: Workaround is to change 180 to 180.0 in the example above, indicating a problem with integer conversion in the compiler.)

@MattGertz MattGertz added this to the 1.2 milestone Dec 1, 2015

@MattGertz MattGertz changed the title from VBC crash in Integer conversion to VBC crash in Double to Decimal conversion Dec 1, 2015

Contributor

MattGertz commented Dec 1, 2015

Note that this fails too:

    Dim d As Double = 180 / Math.PI
    _rotation *= d / Math.PI 'This line causes '"vbc.exe" exited with code -2146232797'

It's the second line that causes the crash, so it seems that the actual problem is the conversion from Double to Decimal -- Integer has nothing to do with it. I'm renaming the issue appropriately.

We will want to get a fix out for this quickly.

@jaredpar jaredpar assigned AlekseyTs and unassigned gafter Dec 1, 2015

Member

jaredpar commented Dec 1, 2015

The immediate issue is occurring in the stack scheduler

Return top.Item2 = If(Not local.IsByRef, ExprContext.Value, ExprContext.Address) AndAlso
  top.Item1.Kind = BoundKind.Local AndAlso
  DirectCast(top.Item1, BoundLocal).LocalSymbol = local

In this scenario top.Item1 is Nothing and hence we NRE on that line. The value Nothing appears to be explicitly legal for Item1 given this line

PushEvalStack(Nothing, ExprContext.Address)

AlekseyTs added a commit to AlekseyTs/roslyn that referenced this issue Dec 1, 2015

@AlekseyTs AlekseyTs added 4 - In Review and removed 3 - Working labels Dec 1, 2015

AlekseyTs added a commit to AlekseyTs/roslyn that referenced this issue Dec 2, 2015

Member

jaredpar commented Dec 2, 2015

After digging into the issue here we determined it will reproduce under the following circumstance:

  • Compound Operator
  • Left side is an instance field or array element of type Decimal
  • Right side is an expression of type Double or Single
Contributor

AlekseyTs commented Dec 2, 2015

@agocke Please verify.

@AlekseyTs AlekseyTs closed this Dec 2, 2015

@AlekseyTs AlekseyTs assigned agocke and unassigned AlekseyTs Dec 2, 2015

AlekseyTs added a commit to AlekseyTs/roslyn that referenced this issue Dec 2, 2015

AlekseyTs added a commit that referenced this issue Dec 2, 2015

Merge pull request #7189 from AlekseyTs/Issue7148_2
Add unit-test with array element for #7148.
Member

jaredpar commented Dec 4, 2015

For anyone effected by this bug you can work around it by doing the following:

  • Open the affected project in Visual Studio
  • Open the Package Manager Console (Tools -> NuGet Package Manager -> Package Manager Console)
  • Run: Install-package Microsoft.Net.Compilers -version 1.1.1

That will install a patched version of the compiler.

I just ran into this today. Will try installing the patched version to see if that fixes it.

edit: Hmm, not quite. Here's what I get now:

C:\Projects\xxx\packages\Microsoft.Net.Compilers.1.1.1\tools\Microsoft.VisualBasic.Core.targets(56,5): error MSB6006: "vbc.exe" exited with code 255.

Just going to use VS2013 as a workaround for now, this isn't even a project my team works on, I'm working on something else and it depends on this project... so I don't have time to fiddle around.

Member

jaredpar commented Dec 9, 2015

@kamranayub do you have a solution you can share out so we can look into this? We've been able to verify that particular bug is fixed in that NuGet (manual testing and customer machines). I'ts possible you are running into a different problem.

The project I ran into for this isn't a primary thing I work with and I
remember it has a ton of interdependencies. I can try to isolate the error
for the project and see if I can provide more info.

On Wed, Dec 9, 2015, 12:38 Jared Parsons notifications@github.com wrote:

@kamranayub https://github.com/kamranayub do you have a solution you
can share out so we can look into this? We've been able to verify that
particular bug is fixed in that NuGet (manual testing and customer
machines). I'ts possible you are running into a different problem.


Reply to this email directly or view it on GitHub
#7148 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment