guyskk / guyskk/pyv8

JSEngine setMemoryAllocationCallback bug

Open
#129 1 comment 0 reactions 0 assignees View on GitHub
auto-migrated OpSys-All Priority-Medium Type-Defect
Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

```

I identified what seems to be a bug in JSEngine setMemoryAllocationCallback
method. In order to reproduce it I used the attached snippet (which is quite
similar to one of the tests included in the tree). Executing the code does not
return the expected results.

buffer@alnitak ~ $ python MemAlloc.py
{}

Moreover the test included in PyV8.py is not really complete

2087 def testMemoryAllocationCallback(self):
2088 alloc = {}
2089
2090 def callback(space, action, size):
2091 alloc[(space, action)] = alloc.setdefault((space, action), 0)
+ size
2092
2093 JSEngine.setMemoryAllocationCallback(callback)
2094
2095 with JSContext() as ctxt:
2096 self.assertEquals({}, alloc)
2097
2098 ctxt.eval("var o = new Array(1000);")
2099
2100 alloc.has_key((JSObjectSpace.Code, JSAllocationAction.alloc))
2101
2102 JSEngine.setMemoryAllocationCallback(None)

As you can see it does not check if the alloc dict is updated as result of the
callback invocation.

Am I missing something or it's really a bug?

Additional details

buffer@alnitak ~/pyv8 $ svn info
Path: .
URL: http://pyv8.googlecode.com/svn/trunk
Repository Root: http://pyv8.googlecode.com/svn
Repository UUID: 3b770cb8-f9e6-11dd-ac5b-dfceb64ead24
Revision: 445
Node Kind: directory
Schedule: normal
Last Changed Author: flier.lu@gmail.com
Last Changed Rev: 443
Last Changed Date: 2012-06-21 15:38:06 +0200 (Thu, 21 Jun 2012)

buffer@alnitak ~/v8 $ svn info
Path: .
URL: http://v8.googlecode.com/svn/trunk
Repository Root: http://v8.googlecode.com/svn
Repository UUID: ce2b1a6d-e550-0410-aec6-3dcde31c8c00
Revision: 12249
Node Kind: directory
Schedule: normal
Last Changed Author: jkummerow@chromium.org
Last Changed Rev: 12243
Last Changed Date: 2012-08-01 13:14:42 +0200 (Wed, 01 Aug 2012)

```

Original issue reported on code.google.com by `angelo.d...@gmail.com` on 1 Aug 2012 at 3:14

Attachments:
- [MemAlloc.py](https://storage.googleapis.com/google-code-attachments/pyv8/issue-129/comment-0/MemAlloc.py)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the attached MemAlloc.py reproduction and PyV8.py:testMemoryAllocationCallback. Run the reproduction, inspect how JSEngine.setMemoryAllocationCallback is invoked around JSContext evaluation, and complete the test so it verifies that the allocation dictionary is updated by the callback.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.