Skip to content

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

Open
@cchando

Description

@cchando
   (<: +&$: <:^: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 @.:

   ([: +&$:/ <:^: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 "$@"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions