jsoftware / jsource

J engine source mirror
Other
658 stars 90 forks source link

J gives wrong result from certain verbs modified by memo (M.), and crashes #208

Open cchando opened 2 months ago

cchando commented 2 months ago
   (<: +&$: <:^:2)`]@.(1&>:)M. 32      NB. fibonacci using M.
2178309
   ([: +&$:/ <:^:1 2)`]@.(1&>:)M. 32   NB. this variation gives wrong result and crashes
3010349
JE has crashed, likely due to an internal bug.  Please report the code which caused the crash, as well as the following printout, to the J forum.
0000000000403132: ?:0:  ?
0000753e262131cf: ?:0:  ?
0000753e2627b574: ?:0:  ?
0000753e219c9fb2: ?:0:  ?
0000753e219c9f44: ?:0:  ?
0000753e219c9420: ?:0:  ?
0000753e219b94d4: ?:0:  ?
0000753e219b900c: ?:0:  ?
000000000040306f: ?:0:  ?
0000753e261fbe07: ?:0:  ?
0000753e261fbecb: ?:0:  ?
00000000004024dd: ?:0:  ?
ffffffffffffffff: ?:0:  ?
-----------------------------------------------------------------------------
/home/cam/Programs/j9.6/jconsole.sh: line 6: 139695 Aborted                 (core dumped) bin/jconsole "$@"

The wrong result and subsequent crash occur in J9.5 and the J9.6 beta.

Versions:

   JVERSION
Engine: j9.5.2/j64/linux
Build: commercial/2024-02-02T18:39:10/clang-11-0-0/SLEEF=1
Library: 9.5.6
Platform: Linux 64
Installer: j9.5 install
InstallPath: /home/cam/Programs/j9.5
Contact: www.jsoftware.com
   JVERSION
Engine: j9.6.0-beta16/j64avx2/linux
Build: commercial/2024-08-09T21:00:21/clang-11-0-0/SLEEF=1
Library: 9.6.8
Platform: Linux 64
Installer: j9.6 install
InstallPath: /home/cam/Programs/j9.6
Contact: www.jsoftware.com

The latter sentence containing ([: +&$:/ <:^1 2)… (or ([: +&$:/ -&1,-&2)…, etc.) crashes on inputs greater than 3.

It produces the correct result in the J903 iOS app and JPlayground, and does not crash except on very large inputs:

   ([: +&$:/ <:^:1 2)`]@.(1&>:)M. 32
2178309
   ([: +&$:/ <:^:1 2)`]@.(1&>:)M. 322
8.80106e66
   JVERSION
Engine: j903/j64/iOS
beta-k: GPL3/2023-04-16T23:21:00
Platform: iOS/iPadOS
Version: 903.2 57
Installer: App Store
Contact: www.jsoftware.com
   ([: +&$:/ <:^:1 2)`]@.(1&>:)M. 3222
(iOS app crashes)

All remaining output below is from the J9.06 beta and presumably would be the same in J9.05.

In another instance it gave a "double free or corruption (out)" error:

    (<: +&$: -&2)`]@.(1&>:)M. 322       NB. reliable version
8.80106e66
    (<: +&$: -&2)`]@.(1&>:)M. 3222      NB. reliable version
_
    ([: +&$:/ <:^:1 2)`]@.(1&>:)M. 32   NB. crashing version
3010349
double free or corruption (out)
/home/cam/Programs/j9.6/jconsole.sh: line 6: 12973 Aborted                 (core dumped) bin/jconsole "$@"

The next time, J crashed only upon running the computation twice:

      ([: +&$:/ <:^:1 , <:^:2)`]@.(1&>:)M. 32
3010349
      ([: +&$:/ <:^:1 2)`]@.(1&>:)M. 32
JE has crashed, likely due to an internal bug.  Please report the code which caused the crash, as well as the following printout, to the J forum.
0000000000403132: ?:0:  ?
0000763cbd9741cf: ?:0:  ?
0000763cb8fed89f: ?:0:  ?
0000763cb9073a23: ?:0:  ?
0000763cb9076af9: ?:0:  ?
0000763cb905ddc6: ?:0:  ?
0000763cb90765c8: ?:0:  ?
0000763cb909762e: ?:0:  ?
0000763cb8fed9e1: ?:0:  ?
0000763cb90fbd2e: ?:0:  ?
0000763cb90fba2c: ?:0:  ?
0000763cb9100f29: ?:0:  ?
0000763cb90e6cbe: ?:0:  ?
0000763cb90e6a97: ?:0:  ?
000000000040306f: ?:0:  ?
0000763cbd95ce07: ?:0:  ?
0000763cbd95cecb: ?:0:  ?
00000000004024dd: ?:0:  ?
ffffffffffffffff: ?:0:  ?
-----------------------------------------------------------------------------
/home/cam/Programs/j9.6/jconsole.sh: line 6: 13062 Aborted                 (core dumped) bin/jconsole "$@"

   (+&$:/@:(<:^:(1 2)))`]@.(1&>:)M. 32    NB. @: instead of [:
3010349
double free or corruption (out)
/home/cam/Programs/j9.6/jconsole.sh: line 6: 13107 Aborted                 (core dumped) bin/jconsole "$@"

At first J did not crash when constructing the equivalent sentence using ^: instead of code>@.</code:

   ([: +&$:/ <:^:1 2)^:(1&<)M. 32
3010349
   ([: +&$:/ <:^:1 2)^:(1&<)M. 32
3010349
   ([: +&$:/ <:^:1 2)^:(1&<)M. 32
3010349
   ([: +&$:/ <:^:1 2)^:(1&<)M. 32
3010349
   ([: +&$:/ <:^:1 2)^:(1&<)M. 32
3010349
   ([: +&$:/ <:^:1 2)^:(1&<)M. 32
3010349

But, in a subsequent session the ^: variation gave a different error, "free(): invalid pointer":

   ([: +&$:/ <:^:1 2)^:(1&<)M. 4
4
free(): invalid pointer
/home/cam/Programs/j9.6/jconsole.sh: line 6: 14067 Aborted                 (core dumped) bin/jconsole "$@"
HenryHRich commented 2 months ago

I should have given a workaround: apply memu to the result of the u in u M.

Henry Rich

On Mon, Aug 19, 2024, 11:42 AM Henry Rich @.***> wrote:

Fixed for next beta. u M. did not properly handle virtual results from u.

Henry Rich

On 8/18/2024 11:44 PM, Cameron Chandoke wrote:

(<: +&$: @.(1&> @.(1&>:)M. 32 NB. fibonacci using M. 2178309 ([: +&$:/ <:^:(1 @.***(1&>:)M. 32 NB. crashing variation that I thought would be equivalent 3010349 JE has crashed, likely due to an internal bug. Please report the code which caused the crash, as well as the following printout, to the J forum. 0000000000403132: ?:0: ? 0000753e262131cf: ?:0: ? 0000753e2627b574: ?:0: ? 0000753e219c9fb2: ?:0: ? 0000753e219c9f44: ?:0: ? 0000753e219c9420: ?:0: ? 0000753e219b94d4: ?:0: ? 0000753e219b900c: ?:0: ? 000000000040306f: ?:0: ? 0000753e261fbe07: ?:0: ? 0000753e261fbecb: ?:0: ? 00000000004024dd: ?:0: ? ffffffffffffffff: ?:0: ?

/home/cam/Programs/j9.6/jconsole.sh: line 6: 139695 Aborted (core dumped) bin/jconsole "$@"

Version:

JVERSION Engine: j9.6.0-beta16/j64avx2/linux Build: commercial/2024-08-09T21:00:21/clang-11-0-0/SLEEF=1 Library: 9.6.8 Platform: Linux 64 Installer: j9.6 install InstallPath: /home/cam/Programs/j9.6 Contact: www.jsoftware.com

I haven't figured out why the results are different between these two calls, either. It seems like they should match.

I've since verified that the second sentence crashes on inputs greater than 3.

Another time it gave a "double free or corruption (out)" error:

(<: +&$: ***@***.***(1&> ***@***.***(1&>:)M. 322

8.80106e66 (<: +&$: @.(1&> @.(1&>:)M. 3222 _ ([: +&$:/ <:^:(1 @.***(1&>:)M. 32 NB. crashing version 3010349 double free or corruption (out) /home/cam/Programs/j9.6/jconsole.sh: line 6: 12973 Aborted (core dumped) bin/jconsole "$@"

The next time, J crashes only upon running the computation twice:

  ([: +&$:/ <:^:1 , ***@***.***(1&> ***@***.***(1&>:)M. 32

3010349 ([: +&$:/ <:^:1 , @.(1&> @.(1&>:)M. 32 JE has crashed, likely due to an internal bug. Please report the code which caused the crash, as well as the following printout, to the J forum. 0000000000403132: ?:0: ? 0000763cbd9741cf: ?:0: ? 0000763cb8fed89f: ?:0: ? 0000763cb9073a23: ?:0: ? 0000763cb9076af9: ?:0: ? 0000763cb905ddc6: ?:0: ? 0000763cb90765c8: ?:0: ? 0000763cb909762e: ?:0: ? 0000763cb8fed9e1: ?:0: ? 0000763cb90fbd2e: ?:0: ? 0000763cb90fba2c: ?:0: ? 0000763cb9100f29: ?:0: ? 0000763cb90e6cbe: ?:0: ? 0000763cb90e6a97: ?:0: ? 000000000040306f: ?:0: ? 0000763cbd95ce07: ?:0: ? 0000763cbd95cecb: ?:0: ? 00000000004024dd: ?:0: ? ffffffffffffffff: ?:0: ?

/home/cam/Programs/j9.6/jconsole.sh: line 6: 13062 Aborted (core dumped) bin/jconsole "$@"

(+&$:/@:(<:^:(1 @.***(1&>:)M. 32 NB. @: instead of [: 3010349 double free or corruption (out) /home/cam/Programs/j9.6/jconsole.sh: line 6: 13107 Aborted (core dumped) bin/jconsole "$@"

(100&+^:(1 2) -: (100&+ , 100&+^:2)) 10 NB. seems like {{u^:(1 2)}} and {{u,u^:2}} should always match... 1

At first J did not crash when constructing the equivalent sentence using ^: instead of @.:

([: +&$:/ <:^:(1 2))^:(1&<)M. 32 3010349 ([: +&$:/ <:^:(1 2))^:(1&<)M. 32 3010349 ([: +&$:/ <:^:(1 2))^:(1&<)M. 32 3010349 ([: +&$:/ <:^:(1 2))^:(1&<)M. 32 3010349 ([: +&$:/ <:^:(1 2))^:(1&<)M. 32 3010349 ([: +&$:/ <:^:(1 2))^:(1&<)M. 32 3010349

But, in a subsequent session the ^: variation gave a different error, "free(): invalid pointer":

([: +&$:/ <:^:(1 2))^:(1&<)M. 4 4 free(): invalid pointer /home/cam/Programs/j9.6/jconsole.sh: line 6: 14067 Aborted (core dumped) bin/jconsole "$@"

— Reply to this email directly, view it on GitHub https://github.com/jsoftware/jsource/issues/208, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKVAJZIF6JXNF2UGBL3OETZSFSYJAVCNFSM6AAAAABMW76GSKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ3TEMZYHEYTKOI . You are receiving this because you are subscribed to this thread.Message ID: @.***>