Hey there.
I am working on a rather good-going idea, of modding the NodeJS core. Now, I
want to create a nodejs instance, that should thread in the background. So I am
just giving it a script, and letting it work all its way in the background.
The idea is to embed nodejs with CEF, but letting nodejs serve different things
from the background. The more internal details I can explain in private, but I
am more interested in this code block at the moment:
struct _Args_t { int arg_c; char** arg_v; } Args;
void* runner(void* data) {
cout << "Args: " << Args.arg_v[0] << endl;
node::Start(Args.arg_c, Args.arg_v);
return NULL;
}
int main(int argc, char *argv[]) {
// Init the struct.
Args.arg_c=argc;
Args.arg_v=(char**)argv;
cout << "..." << endl;
pthread_t thatOtherThread;
pthread_create(&thatOtherThread, NULL, runner, NULL);
pthread_detach(thatOtherThread);
sleep(5);
return 0;
}
As you see, I am launching nodejs in the background with the given arguments.
Thats just a sample implementation at the moment. But when I run this, I get a
nice crash. I ran it thru a debugger, this is what I am getting:
$ lldb ./out/Debug/node
Current executable set to './out/Debug/node' (x86_64).
(lldb) run
Process 1163 launched: './out/Debug/node' (x86_64)
...
Args: ./out/Debug/node
#
# Fatal error in ../../deps/v8/src/v8threads.cc, line 48
# CHECK(isolate != __null) failed
#
==== C stack trace ===============================
1: ??
2: ??
3: ??
4: ??
5: ??
6: ??
7: ??
8: ??
9: ??
Process 1163 stopped
* thread #2: tid = 0x213e41, 0x0000000100836755
node`v8::internal::OS::DebugBreak() + 5 at platform-posix.cc:294, stop reason =
EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
frame #0: 0x0000000100836755 node`v8::internal::OS::DebugBreak() + 5 at
platform-posix.cc:294
291 #else
292 #error Unsupported host architecture.
293 #endif
-> 294 }
295
296
297 //
----------------------------------------------------------------------------
(lldb) bt
* thread #2: tid = 0x213e41, 0x0000000100836755
node`v8::internal::OS::DebugBreak() + 5 at platform-posix.cc:294, stop reason =
EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
frame #0: 0x0000000100836755 node`v8::internal::OS::DebugBreak() + 5 at
platform-posix.cc:294
frame #1: 0x0000000100836749 node`v8::internal::OS::Abort() + 25 at
platform-posix.cc:270
frame #2: 0x0000000100309532 node`V8_Fatal(file=0x000000010099ac09,
line=48, format=0x000000010094ae90) + 498 at checks.cc:107
frame #3: 0x0000000100761667
node`v8::Locker::Initialize(this=0x00000001017c9e88,
isolate=0x0000000000000000) + 71 at v8threads.cc:48
frame #4: 0x000000010001e73d
node`v8::Locker::Locker(this=0x00000001017c9e88, isolate=0x0000000000000000) +
29 at v8.h:5214
frame #5: 0x000000010001dd6d
node`v8::Locker::Locker(this=0x00000001017c9e88, isolate=0x0000000000000000) +
29 at v8.h:5214
frame #6: 0x000000010001c4bf node`node::Start(argc=1,
argv=0x0000000101900000) + 159 at node.cc:3540
frame #7: 0x0000000100001139 node`runner(data=0x0000000000000000) + 89 at
node_main.cc:75
frame #8: 0x00007fff8f8fd899 libsystem_pthread.dylib`_pthread_body + 138
frame #9: 0x00007fff8f8fd72a libsystem_pthread.dylib`_pthread_start + 137
frame #10: 0x00007fff8f901fc9 libsystem_pthread.dylib`thread_start + 13
I will be reporting to the v8-users list too, but if anybody has an explanation
of what is happening here, please tell me.
Kind regards, Ingwie.
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.