Igalia / pflua

Packet filtering in Lua
Other
313 stars 39 forks source link

Possible optimizer bug (#2) #121

Closed kbara closed 9 years ago

kbara commented 9 years ago

This may or may not be a dup of https://github.com/Igalia/pflua/issues/120 . It's also a reminder that test case minimization is useful.

--- Expanded:
{ "if",
  { "if",
    { ">=",
      "len",
      { "+",
        0,
        2 } },
    { "if",
      { ">=",
        "len",
        { "+",
          { "uint32",
            { "+",
              2147483648,
              { "uint32",
                { "-",
                  2147483648,
                  { "ntohs",
                    { "[]",
                      0,
                      2 } } } } } },
          2 } },
      { "if",
        { ">=",
          "len",
          { "+",
            { "ntohs",
              { "[]",
                { "uint32",
                  { "+",
                    2147483648,
                    { "uint32",
                      { "-",
                        2147483648,
                        { "ntohs",
                          { "[]",
                            0,
                            2 } } } } } },
                2 } },
            1 } },
        { "<",
          "len",
          { "[]",
            { "ntohs",
              { "[]",
                { "uint32",
                  { "+",
                    2147483648,
                    { "uint32",
                      { "-",
                        2147483648,
                        { "ntohs",
                          { "[]",
                            0,
                            2 } } } } } },
                2 } },
            1 } },
        { "fail" } },
      { "fail" } },
    { "fail" } },
  { "if",
    { "if",
      { "fail" },
      { "if",
        { "false" },
        { "if",
          { "if",
            { ">=",
              "len",
              { "+",
                "len",
                4 } },
            { "if",
              { ">=",
                "len",
                { "+",
                  "len",
                  2 } },
              { "if",
                { "!=",
                  "len",
                  0 },
                { "if",
                  { ">=",
                    "len",
                    { "+",
                      2147483648,
                      2 } },
                  { "if",
                    { "!=",
                      { "ntohs",
                        { "[]",
                          2147483648,
                          2 } },
                      0 },
                    { "if",
                      { ">=",
                        "len",
                        { "+",
                          2443049855,
                          4 } },
                      { "if",
                        { "!=",
                          1,
                          0 },
                        { "if",
                          { "!=",
                            2147483647,
                            0 },
                          { "<",
                            { "uint32",
                              { "ntohs",
                                { "[]",
                                  "len",
                                  4 } } },
                            { "uint32",
                              { "+",
                                { "uint32",
                                  { "-",
                                    { "uint32",
                                      { "+",
                                        "len",
                                        { "uint32",
                                          { "-",
                                            { "uint32",
                                              { "/",
                                                { "uint32",
                                                  { "+",
                                                    { "uint32",
                                                      { "+",
                                                        { "uint32",
                                                          { "/",
                                                            { "ntohs",
                                                              { "[]",
                                                                "len",
                                                                2 } },
                                                            "len" } },
                                                        { "uint32",
                                                          { "/",
                                                            "len",
                                                            { "ntohs",
                                                              { "[]",
                                                                2147483648,
                                                                2 } } } } } },
                                                    { "uint32",
                                                      { "ntohs",
                                                        { "[]",
                                                          2443049855,
                                                          4 } } } } },
                                                1 } },
                                            { "uint32",
                                              { "/",
                                                3581410568,
                                                2147483647 } } } } } },
                                    "len" } },
                                "len" } } },
                          { "fail" } },
                        { "fail" } },
                      { "fail" } },
                    { "fail" } },
                  { "fail" } },
                { "fail" } },
              { "fail" } },
            { "fail" } },
          { "false" },
          { "<",
            "len",
            0 } },
        { "if",
          { "fail" },
          { "if",
            { "if",
              { ">=",
                "len",
                { "+",
                  1,
                  4 } },
              { "if",
                { ">=",
                  "len",
                  { "+",
                    4294967295,
                    4 } },
                { "<",
                  { "uint32",
                    { "-",
                      { "uint32",
                        { "ntohs",
                          { "[]",
                            1,
                            4 } } },
                      306889473 } },
                  { "uint32",
                    { "ntohs",
                      { "[]",
                        4294967295,
                        4 } } } },
                { "fail" } },
              { "fail" } },
            { "fail" },
            { "if",
              { "false" },
              { "false" },
              { "true" } } },
          { "fail" } } },
      { "if",
        { "true" },
        { "if",
          { "if",
            { ">=",
              "len",
              { "+",
                { "uint32",
                  { "-",
                    441765858,
                    916270296 } },
                2 } },
            { "<",
              { "ntohs",
                { "[]",
                  { "uint32",
                    { "-",
                      441765858,
                      916270296 } },
                  2 } },
              "len" },
            { "fail" } },
          { ">",
            2147483647,
            2147483647 },
          { "if",
            { "true" },
            { "if",
              { ">=",
                "len",
                { "+",
                  4294967295,
                  4 } },
              { ">",
                "len",
                { "uint32",
                  { "ntohs",
                    { "[]",
                      4294967295,
                      4 } } } },
              { "fail" } },
            { "if",
              { ">=",
                "len",
                { "+",
                  515383345,
                  2 } },
              { "<",
                { "ntohs",
                  { "[]",
                    515383345,
                    2 } },
                { "uint32",
                  { "-",
                    0,
                    "len" } } },
              { "fail" } } } },
        { "fail" } } },
    { "false" },
    { "if",
      { ">=",
        "len",
        { "+",
          1,
          2 } },
      { "<",
        "len",
        { "ntohs",
          { "[]",
            1,
            2 } } },
      { "fail" } } },
  { "true" } }
--- Optimized:
{ "fail" }
On packet 14928: unoptimized was true, optimized was false
Rerun as: pflua-quickcheck --seed=864470519 --iterations=852 properties/opt_eq_unopt data/wingolog.pcap test-filters
make: *** [quickcheck] Error 1
kbara commented 9 years ago

Using https://github.com/Igalia/pflua/pull/125 , I have confirmed that this bug appears to be a duplicate of https://github.com/Igalia/pflua/issues/120 .

wingo commented 9 years ago

@kbara can you verify that this is fixed after #120? thanks :)

wingo commented 9 years ago

hah, it seems i hadn't refreshed the page. never mind! :)