Community Development (Terracotta Server)
  1. Community Development (Terracotta Server)
  2. CDV-1234

clone() on shared array types might fail to resolve values before native cloning

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: 1 Critical 1 Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.1
    • Component/s: Byte Code Transform
    • Labels:
      None
    • Severity:
      3 Feature failure (but usable), workaround available
    • Fix In Branch:
      trunk

      Description

      This only effects code compiled with 1.5 or greater I think. com.tc.object.bytecode.TransparencyCodeAdapter.handleJavaLangObjectMethodCall(int, String, String, String) is making a wrong assumption. The call to clone() is made directly to the array type. Example:

      public static void main(String[] args)

      { String[] args2 = args.clone(); System.err.println(args2); }

      If compiled with 1.4, the clone calls looks like this:
      mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "clone", "()Ljava/lang/Object;");

      If compiled with 1.5, the clone calls looks like this:
      mv.visitMethodInsn(INVOKEVIRTUAL, "[Ljava/lang/String;", "clone", "()Ljava/lang/Object;");

      Since the call isn't direct to java.lang.Object we won't insert our magic wrapping that makes sure the element values are resolved (and done within the resolve lock)

        Issue Links

          Activity

          Hide
          Tim Eck added a comment -

          This is definitely broken – and now fixed in trunk. Need to merge to 3.0 when the branch is open

          Show
          Tim Eck added a comment - This is definitely broken – and now fixed in trunk. Need to merge to 3.0 when the branch is open
          Hide
          Kalai Kannaiyan added a comment -

          Tim added test ArrayCloneTest.

          Show
          Kalai Kannaiyan added a comment - Tim added test ArrayCloneTest.

            People

            • Assignee:
              Tim Eck
              Reporter:
              Tim Eck
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: