go2hx icon indicating copy to clipboard operation
go2hx copied to clipboard

Panic recovery not working in math/bits.TestAdd64OverflowPanic test for JVM

Open elliott5 opened this issue 3 years ago • 13 comments

Go test code: https://cs.opensource.google/go/go/+/refs/tags/go1.19.1:src/math/bits/bits_test.go;l=809

In good news, the tests run all all targets, in bad news they all fail around the same point.

Results (from go2hxdoc testing):

C++

=== RUN   TestUintSize
--- PASS: TestUintSize (6.103515625e-05)
=== RUN   TestLeadingZeros
--- PASS: TestLeadingZeros (0.0439059734344482)
=== RUN   TestTrailingZeros
--- PASS: TestTrailingZeros (0.0128650665283203)
=== RUN   TestOnesCount
--- PASS: TestOnesCount (0.0868051052093506)
=== RUN   TestRotateLeft
--- PASS: TestRotateLeft (7.98702239990234e-05)
=== RUN   TestReverse
--- PASS: TestReverse (0.00218892097473145)
=== RUN   TestReverseBytes
--- PASS: TestReverseBytes (0.000133037567138672)
=== RUN   TestLen
--- PASS: TestLen (0.0389060974121094)
=== RUN   TestAddSubUint
--- PASS: TestAddSubUint (0.000346899032592773)
=== RUN   TestAddSubUint32
--- PASS: TestAddSubUint32 (6.19888305664062e-05)
=== RUN   TestAddSubUint64
--- PASS: TestAddSubUint64 (0.000586032867431641)
=== RUN   TestAdd64OverflowPanic
Exception: overflow

HashLink

=== RUN   TestUintSize
--- PASS: TestUintSize (0.000573158264160156)
=== RUN   TestLeadingZeros
--- PASS: TestLeadingZeros (3.21354007720947)
=== RUN   TestTrailingZeros
--- PASS: TestTrailingZeros (2.66197419166565)
=== RUN   TestOnesCount
--- PASS: TestOnesCount (5.26837182044983)
=== RUN   TestRotateLeft
--- PASS: TestRotateLeft (0.00327396392822266)
=== RUN   TestReverse
--- PASS: TestReverse (0.0835380554199219)
=== RUN   TestReverseBytes
--- PASS: TestReverseBytes (0.00529909133911133)
=== RUN   TestLen
--- PASS: TestLen (1.7319221496582)
=== RUN   TestAddSubUint
--- PASS: TestAddSubUint (0.00153088569641113)
=== RUN   TestAddSubUint32
--- PASS: TestAddSubUint32 (0.000973939895629883)
=== RUN   TestAddSubUint64
--- PASS: TestAddSubUint64 (0.00242495536804199)
=== RUN   TestAdd64OverflowPanic
Exception: overflow
Called from stdgo.math.bits_test._Bits_test.$Bits_test_Fields_.~testAdd64OverflowPanic.0 (math/bits_test/Bits_test.hx line 1206)
Called from stdgo.math.bits_test._Bits_test.$Bits_test_Fields_.~testAdd64OverflowPanic.7 (math/bits_test/Bits_test.hx line 1278)
Called from stdgo.math.bits_test._Bits_test.$Bits_test_Fields_.~testAdd64OverflowPanic.6 (math/bits_test/Bits_test.hx line 1253)
Called from stdgo.math.bits_test._Bits_test.$Bits_test_Fields_.testAdd64OverflowPanic (math/bits_test/Bits_test.hx line 1277)
Called from stdgo.testing.M.run (testing/Testing.hx line 353)
Called from stdgo.math.bits_test._Bits.$Bits_Fields_.main (math/bits_test/Bits.hx line 245)

Interp

=== RUN   TestUintSize
--- PASS: TestUintSize (0.000231027603149414062)
=== RUN   TestLeadingZeros
--- PASS: TestLeadingZeros (1.83579707145690918)
=== RUN   TestTrailingZeros
--- PASS: TestTrailingZeros (2.08743000030517578)
=== RUN   TestOnesCount
--- PASS: TestOnesCount (9.70176815986633301)
=== RUN   TestRotateLeft
--- PASS: TestRotateLeft (0.00516104698181152344)
=== RUN   TestReverse
--- PASS: TestReverse (0.137209892272949219)
=== RUN   TestReverseBytes
--- PASS: TestReverseBytes (0.0046939849853515625)
=== RUN   TestLen
--- PASS: TestLen (3.18920993804931641)
=== RUN   TestAddSubUint
--- PASS: TestAddSubUint (0.000504970550537109375)
=== RUN   TestAddSubUint32
--- PASS: TestAddSubUint32 (0.000256061553955078125)
=== RUN   TestAddSubUint64
--- PASS: TestAddSubUint64 (0.00116109848022460938)
=== RUN   TestAdd64OverflowPanic
Exception: overflow
Called from local function #1 (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits_test.hx line 1206 column 4)
Called from local function #7 (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits_test.hx line 1425 column 72)
Called from local function #6 (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits_test.hx line 1253 column 5)
Called from stdgo.math.bits_test._Bits_test.Bits_test_Fields_.testAdd64OverflowPanic (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits_test.hx line 1277 column 3)
Called from stdgo.testing.M.run (/usr/local/lib/haxe/lib/go2hx/git/stdgo/testing/Testing.hx line 353 column 5)
Called from stdgo.math.bits_test._Bits.Bits_Fields_.main (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits.hx line 245 column 11)

JVM

=== RUN   TestUintSize
--- PASS: TestUintSize (0.006999969482421875)
=== RUN   TestLeadingZeros
--- PASS: TestLeadingZeros (0.10300016403198242)
=== RUN   TestTrailingZeros
--- PASS: TestTrailingZeros (0.014999866485595703)
=== RUN   TestOnesCount
--- PASS: TestOnesCount (0.5390000343322754)
=== RUN   TestRotateLeft
--- PASS: TestRotateLeft (9.999275207519531E-4)
=== RUN   TestReverse
--- PASS: TestReverse (0.009000062942504883)
=== RUN   TestReverseBytes
--- PASS: TestReverseBytes (0)
=== RUN   TestLen
--- PASS: TestLen (0.0970001220703125)
=== RUN   TestAddSubUint
--- PASS: TestAddSubUint (0.0019998550415039062)
=== RUN   TestAddSubUint32
--- PASS: TestAddSubUint32 (0)
=== RUN   TestAddSubUint64
--- PASS: TestAddSubUint64 (9.999275207519531E-4)
=== RUN   TestAdd64OverflowPanic
Exception: overflow
Called from stdgo.math.bits_test._Bits_test.Bits_test_Fields_$Closure_testAdd64OverflowPanic_0.invoke (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits_test.hx line 999)
Called from stdgo.math.bits_test._Bits_test.Bits_test_Fields_$Closure_testAdd64OverflowPanic_6.invoke (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits_test.hx line 1278)
Called from stdgo.math.bits_test._Bits_test.Bits_test_Fields_$Closure_testAdd64OverflowPanic_5.invoke (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits_test.hx line 1253)
Called from stdgo.math.bits_test._Bits_test.Bits_test_Fields_$Closure_testAdd64OverflowPanic_5.invoke (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits_test.hx line -1)
Called from stdgo.math.bits_test._Bits_test.Bits_test_Fields_.testAdd64OverflowPanic (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits_test.hx line 1277)
Called from stdgo.math.bits_test._Bits.Bits_Fields_$Bits_test_Fields__testAdd64OverflowPanic.invoke (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits.hx line -1)
Called from stdgo.math.bits_test._Bits.Bits_Fields_$Bits_test_Fields__testAdd64OverflowPanic.invoke (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits.hx line -1)
Called from stdgo.testing.M.run (/usr/local/lib/haxe/lib/go2hx/git/stdgo/testing/Testing.hx line 353)
Called from stdgo.math.bits_test._Bits.Bits_Fields_.main (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits.hx line 245)
Called from stdgo.math.bits_test._Bits.Bits_Fields_.main (/usr/local/lib/haxe/lib/go2hx/git/stdgo/math/bits_test/Bits.hx line 1)

elliott5 avatar Sep 16 '22 06:09 elliott5

I can't reproduce and neither can the action. Could you try testing now with the latest version and if it still occurs, a step by step method would be helpful.

PXshadow avatar Sep 16 '22 20:09 PXshadow

I'll need to wait until the go2hx tests have a green tick, then refresh my copy and try again.

(I just executed the hxcpp binary, .jvm, and .hl files in isolation, and they each showed exactly the same results as above.)

elliott5 avatar Sep 17 '22 05:09 elliott5

I'll need to wait until the go2hx tests have a green tick, then refresh my copy and try again.

(I just executed the hxcpp binary, .jvm, and .hl files in isolation, and they each showed exactly the same results as above.)

Sorry about that fingers crossed in 15 mins there should be a green tick.

Perhaps I could do my changes on branches and then merge them to the master only when the tick is green? Would that be useful for you @elliott5 ?

PXshadow avatar Sep 17 '22 06:09 PXshadow

Yes @PXshadow, only merging your changes when the tick is green would reduce the timing issues between us.

...although I will be deprived of the vicarious enjoyment of seeing each change as the project develops!

elliott5 avatar Sep 17 '22 06:09 elliott5

Yes @PXshadow, only merging your changes when the tick is green would reduce the timing issues between us.

...although I will be deprived of the vicarious enjoyment of seeing each change as the project develops!

Haha 😄 @elliott5 I'll make sure to speedily push in new pull requests into the compiler and not waste time for maximum viewer enjoyment!

PXshadow avatar Sep 17 '22 07:09 PXshadow

I'm afraid I'm still getting the same errors, even with the new version of go2hx and stdgo.

HXML for Eval:

-lib go2hx
-cp bin/stdgo
stdgo.math.bits
stdgo.math.bits_test
-m stdgo.math.bits_test.Bits
--interp

HXML for JVM:

-lib go2hx
-cp bin/stdgo
stdgo.math.bits
stdgo.math.bits_test
-m stdgo.math.bits_test.Bits
--jvm bin/stdgo_math_bits.jvm
--dce full
--cmd java -jar bin/stdgo_math_bits.jvm

HXML for C++:

-lib go2hx
-cp bin/stdgo
stdgo.math.bits
stdgo.math.bits_test
-m stdgo.math.bits_test.Bits
--dce full
--cpp ./bin/hxcpp_common
--cmd ./bin/hxcpp_common/Bits

HXML for HashLink:

-lib go2hx
-cp bin/stdgo
stdgo.math.bits
stdgo.math.bits_test
-m stdgo.math.bits_test.Bits
--hl bin/stdgo_math_bits.hl
--dce full
--cmd hl bin/stdgo_math_bits.hl

elliott5 avatar Sep 17 '22 08:09 elliott5

Okay what Haxe version then @elliott5 ? That is the only thing I can think of I created the hxmls from the commands listed above and did not get the error.

haxe --version
4.3.0-rc.1

PXshadow avatar Sep 18 '22 05:09 PXshadow

Good, my Haxe version is different from yours @PXshadow

% haxe --version
4.2.5

I'll upgrade...

elliott5 avatar Sep 18 '22 05:09 elliott5

Yay happy to get to the bottom of this, I'll see if I can add a Haxe version warning for the compiler when used as a library or ran. Feel free to close this once it works for you :)

PXshadow avatar Sep 18 '22 05:09 PXshadow

I now have

 % haxe --version
4.3.0-rc.1+779b005

In good news, the "math/bits" tests are now all passing for interp/eval!

But fail at TestDivPanicZero for C++ and HashLink; and still at TestAdd64OverflowPanic for JVM.

C++ (extract)

=== RUN   TestDivPanicZero
Exception: Null Function Pointer

HashLink (extract)

=== RUN   TestDivPanicZero
Exception: stdgo.runtime.T_errorString_asInterface has no method error
Called from stdgo.math.bits_test._Bits_test.$Bits_test_Fields_.~testDivPanicZero.1 (stdgo/math/bits_test/Bits_test.hx line 1758)
Called from stdgo.math.bits_test._Bits_test.$Bits_test_Fields_.testDivPanicZero (stdgo/math/bits_test/Bits_test.hx line 1781)
Called from stdgo.testing.M.run (stdgo/testing/Testing.hx line 353)
Called from stdgo.math.bits_test._Bits.$Bits_Fields_.main (stdgo/math/bits_test/Bits.hx line 245)

elliott5 avatar Sep 18 '22 06:09 elliott5

Can confirm I'm able to reproduce the issue on the hashlink target (have not tried c++ or jvm I'm doing one target at a time) I can get it working for hashlink if I use don't use your hxml and instead use the standard test commands for the std library packages.

% haxe stdgo/math_bits.hxml --hl math_bits.hl && hl math_bits.hl

I'll work on fixing the bug thanks for the help reproducing @elliott5 :)

PXshadow avatar Sep 18 '22 06:09 PXshadow

I've tried it without -dce full to see if that is the issue.

Both C++ and HashLink now pass!

JVM still has the same issue.

I'll remove -dce full from my testing.

elliott5 avatar Sep 18 '22 06:09 elliott5

Wonderful, not sure why dce is causing issues perhaps reflection utilization is causing Haxe to dce something needed.

PXshadow avatar Sep 18 '22 17:09 PXshadow

All JVM issues are being closed as the target is no longer supported, and the issues can be revisited in the future when the JVM target gets added back.

PXshadow avatar Nov 08 '23 07:11 PXshadow