RoamUniverse / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

Crash on for/in loop with __getattr__ method defined in python class. #80

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

import PyV8

class Obj(PyV8.JSClass):
    """    
    """

    def __getitem__(self, key):
        print "Inside __getitem__"

class Global(PyV8.JSClass):

    def __init__(self):

        self.obj = Obj()

    def write(self, val):

        print val

with PyV8.JSContext(Global()) as ctx:

    ctx.eval("""

    write(obj);

    for(i in obj) {
        write(i);    
    }

    """)

What is the expected output? What do you see instead?

Expected: Not a crash.

Seen:

<__main__.Obj object at 0x7eff4d6fef10>

#
# Fatal error in src/objects.cc, line 6477
# CHECK(capacity >= 0) failed
#

==== Stack trace ============================================

Security context: 0x7eff46987a81 <JS Object>#0#
    1: /* anonymous */ [/* anonymous */:5] (this=0x7eff46987b89 <JS Global Object>#1#)

==== Details ================================================

[1]: /* anonymous */ [/* anonymous */:5] (this=0x7eff46987b89 <JS Global 
Object>#1#) {
  // stack-allocated locals
  var .result = 0x7eff46912021 <null>
  // expression stack (top to bottom)
  [02] : 0x7eff4801fea1 <JS Object>#2#
  [01] : 0x7eff4801fea1 <JS Object>#2#
--------- s o u r c e   c o d e ---------
??    write(obj);??    for(i in obj) {?        write(i);    ?    }???    
-----------------------------------------
}

==== Key         ============================================

 #0# 0x7eff46987a81: 0x7eff46987a81 <JS Object>
 #1# 0x7eff46987b89: 0x7eff46987b89 <JS Global Object>
 #2# 0x7eff4801fea1: 0x7eff4801fea1 <JS Object>
=====================

Aborted

What version of the product are you using? On what operating system?

Latest SVN.

Please provide any additional information below.

Original issue reported on code.google.com by mbc8...@gmail.com on 25 Mar 2011 at 10:01

GoogleCodeExporter commented 9 years ago
I meant to say __getitem__ instead of __getattr__ in the title.

Original comment by mbc8...@gmail.com on 30 Mar 2011 at 6:46

GoogleCodeExporter commented 9 years ago

Original comment by flier...@gmail.com on 31 Mar 2011 at 2:19

GoogleCodeExporter commented 9 years ago
Sorry, but I can't reproduce your issue, it seems caused by wrong v8 building 
parameters, could you try to build the pyv8 from a clear system with setup.py? 
Or, if you want to build v8, please ensure you have patch its SConstruct files.

btw: what's your os, python, boost and v8 version?

Original comment by flier...@gmail.com on 6 Apr 2011 at 4:37

GoogleCodeExporter commented 9 years ago
Please reopen it when you could reproduce it, thanks.

Original comment by flier...@gmail.com on 10 Aug 2011 at 5:26