Skip to content

the OutOfMemory exception happens in an example with ~250 lines #13

Open

Description

@dours

The example is below. It is a part of the runtime support library for the py2eo translator. By the way, it may be reasonable for you to skip checking the support library, but I don't know of any mechanism for me to explain your analyzer which files are actually the support library.

+package org.eolang
+alias goto org.eolang.goto
+alias stdout org.eolang.io.stdout
+alias sprintf org.eolang.txt.sprintf
+alias cage org.eolang.cage
+junit

[unused] > test
  100.div 0 > @
  [] > raiseNothing
    [] > x__class__
      (pyint 0) > x__id__

  [] > raiseEmpty
    [] > x__class__
      (pyint 4) > x__id__

  [val] > pybool

    memory val > value

    fakeclasses.pyBoolClass > x__class__

    [x] > neq
      pybool (x.value.neq value) > @

    [x] > eq
      pybool (x.value.eq value) > @

    [] > not
      pybool (value.not) > @

    [x] > or
      pybool (value.or (x.value)) > @

    [x] > xor
      pybool (value.xor (x.value)) > @

    [x] > and
      pybool (value.and (x.value)) > @

    [t f] > if
      value.if t f > @

    [f] > while
      value.while f > @

    [] > as-string
      value.as-string > @

    [] > force
      value.write val > @

    value > @

  [] > newUID
    memory 12 > cur
    [unused] > apply
      seq > @
        cur.write (cur.plus (1))
        (pyint cur)

  [value] > pyfloat

    fakeclasses.pyFloatClass > x__class__

    [x] > with-value
      pyfloat x > @

    [x] > eq
      fakeclasses.convert (pyfloat value) x > p
      seq > @
        if.
          (fakeclasses.has-type x (fakeclasses.pyFloatClass))
          pybool (value.eq (x.value))
          p.fst.eq (p.snd)

  [x] > mkCopy
    x' > copy
    copy.< > @

  [res] > return
    res > result
    [] > x__class__
      (pyint 3) > x__id__

  [] > xZeroDivisionError
    pyint 12 > x__id__
    [] > apply
      [stackUp] > @
        cage result > pResult
        [] > result
          xZeroDivisionError > x__class__
        stackUp.forward (return pResult) > @

  [] > fakeclasses
    [xid] > fakeclass
      newUID.apply 0 > xidnormal
      pyint xid > x__id__
      [x] > eq
        pybool (xid.eq (x.xid)) > @

    fakeclass 5 > pyBoolClass
    fakeclass 6 > pyIntClass
    fakeclass 7 > pyFloatClass
    fakeclass 8 > pyComplexClass
    fakeclass 13 > pyStringClass

    [typ1 typ2] > gt
      seq > @
        typ1.xid.gt (typ2.xid)

    [obj typ] > has-type
      obj.x__class__.eq typ > @

    [obj dst] > convert-to
      seq > @
        stdout (sprintf "%s" "convert-to\n")
        if.
          dst.eq pyIntClass
          pyint (obj.value)
          if.
            dst.eq pyFloatClass
            seq
              stdout "converting to float\n"
              obj.as-float
            seq
              stdout "Oblom\n"
              ("Oblom")

    [fst snd] > pair

    [a b] > convert
      seq > @
        stdout "convert\n"
        if.
          gt (a.x__class__) (b.x__class__)
          seq
            pair
              a
              convert-to b (a.x__class__)
          seq
            stdout "false\n"
            pair
              convert-to a (b.x__class__)
              b

  [val] > pyint
    memory val > value

    fakeclasses.pyIntClass > x__class__

    [x] > with-value
      pyint x > @

    [x] > eq
      fakeclasses.convert (pyint value) x > p
      seq > @
        if.
          (fakeclasses.has-type x (fakeclasses.pyIntClass))
          pybool (value.eq (x.value))
          p.fst.eq (p.snd)

    [x] > float-div
      fakeclasses.convert (pyint value) x > p
      seq > @
        if.
          (fakeclasses.has-type x (fakeclasses.pyIntClass))
          (x.value.eq 0).if
            seq
              stdout "division by zero\n"
              (goto (xZeroDivisionError.apply.@)).result
            (return (pyfloat (value.as-float.div (x.value.as-float))))
          p.fst.div (p.snd)

  [] > apply
    [stackUp] > @
      [id] > is-exception
        id.greater (pyint 3) > @
      [id] > is-break-continue-return
        (id.greater (pyint 0)).and (id.less (pyint 4)) > @
      [] > xbool
        [x] > apply
          [stackUp] > @
            seq > @
              stackUp.forward (return x)
              123
      cage 0 > xcurrent-exception
      cage 0 > xexcinexc
      cage FALSE > xcaught
      newUID > dummy-newUID
      fakeclasses.pyFloatClass > xfloat
      fakeclasses.pyComplexClass > xcomplex
      raiseNothing > dummy-rn
      return > dummy-return
      raiseEmpty > dummy-raiseEmpty
      mkCopy > dummy-mkCopy
      xZeroDivisionError > dummy-xZeroDivisionError
      cage 0 > tmp
      cage 0 > toReturn
      cage 0 > assertMe
      cage 0 > xtest
      seq > @
        stdout "div\n"
        write.
          xtest
          []
            [xxNotCopied] > apply
              [stackUp] > @
                cage 0 > tmp
                cage 0 > toReturn
                xxNotCopied' > xx
                cage 0 > e0
                seq > @
                  stdout "xtest\n"
                  xx.<
                  tmp.write (100.div 0)
                  (tmp.x__class__.x__id__.neq (return.x__class__.x__id__)).if (stackUp.forward tmp) 0
                  (e0).write (tmp.result)
                  ((e0).<)
                  toReturn.write ((e0))
                  stackUp.forward (return toReturn)
                  123
        tmp.write (goto ((((xtest)).apply).@))
        (tmp.x__class__.x__id__.neq (return.x__class__.x__id__)).if (stackUp.forward tmp) 0
        (assertMe).write (tmp.result)
        toReturn.write ((assertMe))
        stackUp.forward (return toReturn)

Activity

  1. mnj2kk commented on Aug 11, 2022

    @mnj2kk
    Contributor

    Hello, @dours! Thank you for your message. Can you tell me how you run the polystat?

  2. dours commented on Aug 11, 2022

    @dours
    Author

    Hello @mnj2kk, I run java -jar ~/Downloads/polystat.jar eo --in test.eo --include division-by-zero with the .jar from the polystat-cli project (latest on Aug 3)

  3. dours commented on Aug 12, 2022

    @dours
    Author

    @mnj2kk BTW, this minimized version still fails

    +package org.eolang
    +alias goto org.eolang.goto
    +alias stdout org.eolang.io.stdout
    +alias sprintf org.eolang.txt.sprintf
    +alias cage org.eolang.cage
    +junit
    
    [unused] > test
      100.div 0 > @
      [val] > pybool
    
        memory val > value
    
        fakeclasses.pyBoolClass > x__class__
    
        [x] > eq
          pybool (x.value.eq value) > @
    
        [x] > and
          pybool (value.and (x.value)) > @
    
        [t f] > if
          value.if t f > @
    
        value > @
    
      [] > newUID
        memory 12 > cur
        [unused] > apply
          seq > @
            cur.write (cur.plus (1))
            (pyint cur)
    
      [x] > mkCopy
        x' > copy
        copy.< > @
    
      [res] > return
        res > result
        [] > x__class__
          (pyint 3) > x__id__
    
      [] > fakeclasses
        [xid] > fakeclass
          newUID.apply 0 > xidnormal
          pyint xid > x__id__
          [x] > eq
            pybool (xid.eq (x.xid)) > @
    
        fakeclass 5 > pyBoolClass
        fakeclass 6 > pyIntClass
    
      [val] > pyint
        memory val > value
    
        fakeclasses.pyIntClass > x__class__
    
        [x] > eq
          pybool (value.eq (x.value)) > @
    
      [] > apply
        [stackUp] > @
          cage 0 > tmp
          cage 0 > toReturn
          cage 0 > assertMe
          cage 0 > xtest
          seq > @
            stdout "div\n"
            write.
              xtest
              []
                [xxNotCopied] > apply
                  [stackUp] > @
                    stackUp.forward (return 0)
                    cage 0 > tmp
                    cage 0 > toReturn
                    xxNotCopied' > xx
                    cage 0 > e0
                    seq > @
                      stdout "xtest\n"
                      xx.<
                      stackUp.forward (return toReturn)
                      123
            tmp.write (goto ((((xtest)).apply).@))
            (tmp.x__class__.x__id__.neq (return.x__class__.x__id__)).if (stackUp.forward tmp) 0
            (assertMe).write (tmp.result)
            toReturn.write ((assertMe))
            stackUp.forward (return toReturn)
    

    This one does not

    +package org.eolang
    +alias goto org.eolang.goto
    +alias stdout org.eolang.io.stdout
    +alias sprintf org.eolang.txt.sprintf
    +alias cage org.eolang.cage
    +junit
    
    [unused] > test
      100.div 0 > @
      [val] > pybool
    
        memory val > value
    
        fakeclasses.pyBoolClass > x__class__
    
        [x] > eq
          pybool (x.value.eq value) > @
    
        [x] > and
          pybool (value.and (x.value)) > @
    
        [t f] > if
          value.if t f > @
    
        value > @
    
      [] > newUID
        memory 12 > cur
        [unused] > apply
          seq > @
            cur.write (cur.plus (1))
            (pyint cur)
    
      [x] > mkCopy
        x' > copy
        copy.< > @
    
      [res] > return
        res > result
        [] > x__class__
          (pyint 3) > x__id__
    
      [] > fakeclasses
        [xid] > fakeclass
          newUID.apply 0 > xidnormal
          pyint xid > x__id__
          [x] > eq
            pybool (xid.eq (x.xid)) > @
    
        fakeclass 5 > pyBoolClass
        fakeclass 6 > pyIntClass
    
      [val] > pyint
        memory val > value
    
        fakeclasses.pyIntClass > x__class__
    
        [x] > eq
          pybool (value.eq (x.value)) > @
    
      [] > apply
        [stackUp] > @
          cage 0 > tmp
          cage 0 > toReturn
          cage 0 > assertMe
          cage 0 > xtest
          seq > @
            tmp.write (return (pyint (100.div 0)))
            (tmp.x__class__.x__id__.neq (return.x__class__.x__id__)).if (stackUp.forward tmp) 0
            (e0).write (tmp.result)
            ((e0).<)
            toReturn.write ((e0))
            stackUp.forward (return toReturn)
    

    Also, the following version does not report any errors, though it clearly has a division by zero:

    +package org.eolang
    
    [] > test
      100.div 0 > @
    

    I run it with java -jar ~/Downloads/polystat.jar eo --in test.eo --sarif

  4. mnj2kk commented on Aug 18, 2022

    @mnj2kk
    Contributor

    Can you link to latest version (3 aug)? @dours

  5. dours commented on Aug 24, 2022

    @dours
    Author
  6. mnj2kk commented on Aug 29, 2022

    @mnj2kk
    Contributor

    @dours, i have different error on my m1 mac & win10, whats your system and java version?

  7. dours commented on Aug 29, 2022

    @dours
    Author

    Hello, @mnj2kk, it is ubuntu 20 inside a virtualbox with 8G of memory, java is 14.0.1 . Maybe you have a different memory limit for the java machine (it can be set as an option to java afaik).

  8. added 2 commits that reference this issue on Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions