-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
prevent panic in Value.AsBigFloat() #31
Conversation
Codecov Report
@@ Coverage Diff @@
## master #31 +/- ##
==========================================
- Coverage 75.92% 75.85% -0.08%
==========================================
Files 74 74
Lines 5758 5765 +7
==========================================
+ Hits 4372 4373 +1
- Misses 996 1002 +6
Partials 390 390
Continue to review full report at Codecov.
|
Hmm... thanks for reporting this odd behavior, @azr! My intent here was that a number value should always be a That you are using Lines 49 to 53 in f21e35a
...so indeed it does seem that in the past I found that this problem would occur under Do you happen to have a small code snippet that illustrates the situation you were trying to fix here? I'd ideally like to try to debug it further to see if we can fix the root cause, rather than adding in another conditional branch to treat the symptoms. |
Hey Martin, gotcha ! 3e83fcc adds a tests that provokes the panic. I'll try to see if I can fix at the source 🙂. |
Thanks @azr! It sounds from your comment like you're planning to debug this some more yourself, so I'll leave you to do that for now but feel free to let me know if you'd like me to dig in here and do some debugging too. |
Hello @apparentlymart ! I have been struggling with this one; everything I did caused a panic or made something else panic so I decided to refactor the Number testing to sort of scope it down; which also caused a panic and I may be doing something wrong here 🤔 but it looks like I think the last commit I pushed (67fae68) explains it better. (I think probably only the last tests were passing) Edit: if it's true for Edit2: Looks like this could be very true because t.Run launches a goroutine: https://github.com/golang/go/blob/3922c006ad57f042238e48bb2cd13e5d88499a6c/src/testing/testing.go#L1000-L1005 |
avoid race condition shadowing of tests
Martin, I require your help 🙂 ! Am I doing something wrong here ? Should I test my case somewhere else ? |
Sorry for the delay in responding, @azr. I'll take a closer look at this to see if I can understand what's going on. |
I have tracked down what is required to trigger the panic: it seems to occur when a number appears inside some other collection value, which makes sense because the I'm going to see what it will take to either understand why the |
I think the underlying problem here is related to the fact that This feels like a bug in either |
My theory as to the cause seems indirectly confirmed by golang/go#32251, where a similar problem is observed on |
Hi again, @azr! After a few different attempts I got something that seems to work over in #32. I'm going to land a few other pending PRs here and then tag a release of this module containing the fix. Thanks for the work here to narrow down the problem! In particular your failing test case was very helpful to understand why the existing test |
Ah nice thanks @apparentlymart, yes about the original issue I was under the impression that because go-cty/cty/types_to_register.go Lines 32 to 41 in 14e23b1
Then it could only bubbled up as this type; I was planning on going forward with this but was stuck with a bunch of panics. |
Howdy 🙂 !
this fixes the following
panic: interface conversion: interface {} is big.Float, not *big.Float
I had while using this Func.For context: I have encoded some cty.Values using gob and this might be causing it.