Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd behaviour #72

Open
gleber opened this issue Oct 21, 2012 · 8 comments
Open

Odd behaviour #72

gleber opened this issue Oct 21, 2012 · 8 comments

Comments

@gleber
Copy link
Contributor

gleber commented Oct 21, 2012

I am trying to bring back beamjs to life and I've fixed many issues already. But now I have stumbled at a problem with "require.main" not being set. After fiddling with this problem I have found it to behave very weird:

(<0.2.0>) call beamjs:args(<0.40.0>,load)
(<0.2.0>) call beamjs:'-args/2-fun-2-'("deps/commonjs/tests/unit-testing/1.0/program.js",<0.40.0>)
(<0.2.0>) call erlv8_vm:enqueue_tick(<0.40.0>,{set,<<>>,"xyz","def222"})
(<0.2.0>) returned from erlv8_vm:enqueue_tick/2 -> "def222"
(<0.2.0>) call erlv8_vm:enqueue_tick(<0.40.0>,{get,<<>>,"require"})
(<0.2.0>) returned from erlv8_vm:enqueue_tick/2 -> {erlv8_fun,<<>>,<0.40.0>}
(<0.2.0>) call erlv8_vm:enqueue_tick(<0.40.0>,{call,<<>>,["deps/commonjs/tests/unit-testing/1.0/program.js"]})
(<0.63.0>) call erlv8_vm:enqueue_tick(<0.40.0>,{get,<<>>,"xyz"})
(<0.63.0>) returned from erlv8_vm:enqueue_tick/2 -> <<"def">>

I am setting test global variable "xyz" to "def" initially (right after VM is started), but later on, just before (Global:get_value("require")):call(...), I am setting it to "def222". But inside of "fun require_fun/2" I do Global:get_value("xyz") again and it returns "def".

Any ideas what it could be?

@gleber
Copy link
Contributor Author

gleber commented Oct 21, 2012

Another weird thing is that if I run Global:get_value("xyz") at the very end of the program, it is actually changed to "def222"

@gleber
Copy link
Contributor Author

gleber commented Oct 21, 2012

Here's more debug output: http://pastebin.com/Z6tugSSJ

It include traced gets and sets with pointer of the global object. And it changes a lot, not sure if it is helpful.

@gleber
Copy link
Contributor Author

gleber commented Oct 23, 2012

I've solved this problem with this commit in beamjs:

gleber/beamjs@fbdb748

But source of the problem still persists in erlv8.

@gleber
Copy link
Contributor Author

gleber commented Oct 23, 2012

But this "fix" screws up exports object, which is shared because of my changes. I need to figure out problems with context switching not working properly.

@yrashk
Copy link
Member

yrashk commented Oct 25, 2012

JFYI, I received the message, I'm just a bit overloaded at the moment :-)

@yrashk
Copy link
Member

yrashk commented Oct 25, 2012

But anyway, I am monitoring this.

@gleber
Copy link
Contributor Author

gleber commented Oct 25, 2012

I'll prepare a test case for this problem so you can at least reproduce it

@gleber
Copy link
Contributor Author

gleber commented Nov 14, 2012

I wasn't able to prepare the test case for this problem and I've worked around the problem by replacing explicit use of V8 Contexts with wrapping required file into anonymous JS function, running it and returning module's exports. Code says it all: https://github.com/gleber/beamjs/blob/master/src/beamjs_mod_require.erl#L126

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants