Uploaded image for project: 'HPCC'
  1. HPCC
  2. HPCC-16993

SegFault calling FROMJSON within FUNCTIONMACRO

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.2.4
    • Fix Version/s: 6.2.10
    • Component/s: None
    • Labels:
      None

      Description

      Runnable sample code (assuming that file '~some_existing_file_path' exists):

      Put(filePath, rec) := FUNCTIONMACRO
          IMPORT Std;
          LOCAL recStr := '{' + (STRING)TOJSON(rec) + '}';
          RETURN Std.File.SetFileDescription(filePath, recStr);
      ENDMACRO;
      
      Get_Bad(filePath, recLayout) := FUNCTIONMACRO
          IMPORT Std;
          LOCAL desc := Std.File.GetFileDescription(filePath);
          RETURN FROMJSON
              (
                  recLayout,
                  desc,
                  ONFAIL(TRANSFORM(recLayout, SELF := []))
              );
      ENDMACRO;
      
      Get_Good(filePath, recLayout) := FUNCTIONMACRO
          IMPORT Std;
          LOCAL desc := Std.File.GetFileDescription(filePath);
          LOCAL Convert(STRING j) := FROMJSON
              (
                  recLayout,
                  j,
                  ONFAIL(TRANSFORM(recLayout, SELF := []))
              );
          RETURN Convert(desc);
      ENDMACRO;
      
      //------------------------------------------------------
      
      PATH := '~some_existing_file_path';
      DataLayout := {UNSIGNED4 n};
      
      // Insert rec into description
      Put(PATH, ROW({1000}, DataLayout));
      
      // Extract rec
      OUTPUT(Get_Good(PATH, DataLayout));
      // OUTPUT(Get_Bad(PATH, DataLayout));
      

      The intention here is to take use a file description as a storage area for a single row of data. As-is, the code works.

      To show the error, swap the comments around on the last two lines, so that Get_Bad() is called. The result is a segfault:

      Error:    SIG: Segmentation fault(11), accessing 00007EFBD8DFF008, IP=00007EFCFCD5963C (0, 0), 1000, 
      

      The primary workaround seemed to be the creation of the Convert(STRING j) attribute within Get_Good().

        Attachments

          Activity

            People

            • Assignee:
              ghalliday Gavin Halliday
              Reporter:
              dcamper Dan S. Camper
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: