Skip to content

Commit 34b0a36

Browse files
committed
src: don't use NewExternal() with unaligned strings
V8 3.20.9 enforces that external pointers are aligned on a two-byte boundary. We cannot portably guarantee that for the source code strings that tools/js2c.py generates so simply stop using String::NewExternal() altogether (and by extension String::ExternalAsciiStringResource). Fixes the following run-time assert: FATAL ERROR: v8::String::NewExternal() Pointer is not aligned
1 parent 1bd711c commit 34b0a36

File tree

5 files changed

+7
-112
lines changed

5 files changed

+7
-112
lines changed

node.gyp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
'src/node_os.cc',
102102
'src/node_script.cc',
103103
'src/node_stat_watcher.cc',
104-
'src/node_string.cc',
105104
'src/node_watchdog.cc',
106105
'src/node_zlib.cc',
107106
'src/pipe_wrap.cc',
@@ -127,7 +126,6 @@
127126
'src/node_os.h',
128127
'src/node_root_certs.h',
129128
'src/node_script.h',
130-
'src/node_string.h',
131129
'src/node_version.h',
132130
'src/node_watchdog.h',
133131
'src/node_wrap.h',

src/node.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ typedef int mode_t;
7272
#include "node_constants.h"
7373
#include "node_javascript.h"
7474
#include "node_version.h"
75-
#include "node_string.h"
7675
#if HAVE_OPENSSL
7776
# include "node_crypto.h"
7877
#endif
@@ -2403,6 +2402,8 @@ static void SignalExit(int signal) {
24032402

24042403

24052404
void Load(Handle<Object> process_l) {
2405+
HandleScope handle_scope(node_isolate);
2406+
24062407
process_symbol = String::New("process");
24072408
domain_symbol = String::New("domain");
24082409

@@ -2420,8 +2421,7 @@ void Load(Handle<Object> process_l) {
24202421
// are not safe to ignore.
24212422
try_catch.SetVerbose(false);
24222423

2423-
Local<Value> f_value = ExecuteString(MainSource(),
2424-
IMMUTABLE_STRING("node.js"));
2424+
Local<Value> f_value = ExecuteString(MainSource(), String::New("node.js"));
24252425
if (try_catch.HasCaught()) {
24262426
ReportException(try_catch);
24272427
exit(10);

src/node_javascript.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "v8.h"
2323
#include "node.h"
2424
#include "node_natives.h"
25-
#include "node_string.h"
25+
2626
#include <string.h>
2727
#if !defined(_MSC_VER)
2828
#include <strings.h>
@@ -33,7 +33,7 @@ using namespace v8;
3333
namespace node {
3434

3535
Handle<String> MainSource() {
36-
return BUILTIN_ASCII_ARRAY(node_native, sizeof(node_native)-1);
36+
return String::New(node_native, sizeof(node_native) - 1);
3737
}
3838

3939
void DefineJavaScript(v8::Handle<v8::Object> target) {
@@ -42,7 +42,8 @@ void DefineJavaScript(v8::Handle<v8::Object> target) {
4242
for (int i = 0; natives[i].name; i++) {
4343
if (natives[i].source != node_native) {
4444
Local<String> name = String::New(natives[i].name);
45-
Handle<String> source = BUILTIN_ASCII_ARRAY(natives[i].source, natives[i].source_len);
45+
Handle<String> source = String::New(natives[i].source,
46+
natives[i].source_len);
4647
target->Set(name, source);
4748
}
4849
}

src/node_string.cc

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/node_string.h

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)