Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

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
Closed

VBC crash in Double to Decimal conversion #7148

MattGertz opened this issue Dec 1, 2015 · 8 comments
Assignees
Labels
Area-Compilers Language-VB Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented Tenet-Compatibility Violation of forwards/backwards compatibility in a design-time piece. Urgency-Now
Milestone

Comments

@MattGertz
Copy link
Contributor

(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 Language-VB Area-Compilers Tenet-Compatibility Violation of forwards/backwards compatibility in a design-time piece. Urgency-Now labels Dec 1, 2015
@MattGertz MattGertz added this to the 1.2 milestone Dec 1, 2015
@MattGertz MattGertz changed the title VBC crash in Integer conversion VBC crash in Double to Decimal conversion Dec 1, 2015
@MattGertz
Copy link
Contributor Author

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
@jaredpar
Copy link
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)

@jaredpar
Copy link
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

@AlekseyTs AlekseyTs added Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented and removed 4 - In Review A fix for the issue is submitted for review. labels Dec 2, 2015
@AlekseyTs
Copy link
Contributor

@agocke Please verify.

@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
Add unit-test with array element for #7148.
@jaredpar
Copy link
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.

@kamranayub
Copy link

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.

@jaredpar
Copy link
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.

@kamranayub
Copy link

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
Labels
Area-Compilers Language-VB Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented Tenet-Compatibility Violation of forwards/backwards compatibility in a design-time piece. Urgency-Now
Projects
None yet
Development

No branches or pull requests

6 participants