Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5791

Inconsistent behavior: Go does not use default values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.19.0, 0.20.0
    • None
    • Go - Compiler, Go - Library
    • None

    Description

      Hi,

      We are software engineering researchers working on automated program analysis techniques to improve the reliability of RPC frameworks.

       

      We discover a bug illustrated by the following example (The attached script can help you reproduce the issue).

      When using a .thrift file to define a struct, if one of the fields is optional and has a default i8 value (e.g., 73), there is an inconsistent behavior in implementations across different languages. Specifically:

      1. In the Go implementation, if the field is not explicitly defined or assigned a value, the transmitted value is 0.
      2. In the Python and Node.js implementations, if the field is not explicitly defined or assigned a value, the transmitted value is the default value of 73.

      This inconsistency indicates that there might be an issue with the Go implementation.

      In our setting, we use Go, Node.js, and Python 3 as the server side, and use Go, Node.js, and Python 3, as the client side. The thrift file we use is shown in the flowing picture:

      When calling Method_3, the message passed is an instance of StructClass_0, where f_4 is not set. The f_4 is automatically defined as 0, while in Python 3 and Node.js, f_4 is 73.

      The result is shown as bellow:

      go-py3_json_buffered-ip_client.log

      go-go_json_buffered-ip_client.log

      The attachments provided are essential for reproducing the issue. By following the commands outlined in the accompanying readme.md, you will be able to replicate the problem accurately.

       

      This is our first submission. If you have any preferred methods, please feel free to let us know. Thank you.

      Attachments

        1. temp_thrift.zip
          36.18 MB
          Team_RPCtester
        2. submit_thrift.zip
          35 kB
          Team_RPCtester
        3. image-2024-06-14-21-45-17-915.png
          46 kB
          Team_RPCtester
        4. image-2024-06-14-21-43-51-655.png
          46 kB
          Team_RPCtester
        5. image-2024-06-02-20-16-08-144.png
          30 kB
          Team_RPCtester
        6. image-2024-06-02-20-15-55-606.png
          28 kB
          Team_RPCtester
        7. image-2024-06-02-20-15-37-106.png
          94 kB
          Team_RPCtester

        Activity

          People

            Unassigned Unassigned
            rpctester Team_RPCtester
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: