title: V8: Fatal error: CHECK(V8::ArrayBufferAllocator() != NULL) failed
body: <p>I get this error when I try to run some JS code (<a href="http://pastebin.com/XesBSstJ" rel="nofollow">this</a> + <a href="http://pastebin.com/0VawRb16" rel="nofollow">this</a>) with V8 (tried master from two weaks ago, 3.23.17, 3.24.40, 3.25.5; 3.23.0 doesn't work anymore because of API changes):</p>
  
  <pre><code>#
  # Fatal error in ..\..\src\runtime.cc, line 785
  # CHECK(V8::ArrayBufferAllocator() != NULL) failed
  #
  </code></pre>
  
  <p>A lot of other JS code has worked already, so I wonder what the problem is.</p>
  
  <p>It's on Win8 with a x64 build. V8 has been build just as described in the official docs (using gyp + MSVC 2012). I don't think that there was a problem because it worked fine already with most other JS code.</p>
  
  <p>I think that there might be an issue with V8 itself, but not sure...</p>
  
  <p>I also asked on the mailing-list <a href="https://groups.google.com/forum/#!topic/v8-users/BC-yrxSl3iI" rel="nofollow">here</a>.</p>
  
  <hr>
  
  <p>Some C++ code, but I don't think that there is a problem with it because it worked fine with other JS code:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;assert.h&gt;
  #include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;iomanip&gt;
  #include &lt;boost/noncopyable.hpp&gt;
  #include &lt;v8.h&gt;
  
  
  // Create a new isolate (completely isolated JS VM).
  struct V8Isolate : boost::noncopyable {
      v8::Isolate* isolate;
      V8Isolate() : isolate(v8::Isolate::New()) {}
      ~V8Isolate() { isolate-&gt;Dispose(); }
      operator v8::Isolate*() { return isolate; }
      v8::Isolate* operator-&gt;() { return isolate; }
  };
  
  struct ReturnType {
      std::string err; // non-empty if there is an error
  
      ReturnType(bool success) {
          assert(success);
      }
      ReturnType(const std::string&amp; _err) : err(_err) {
          assert(!err.empty());
      }
      ReturnType(const char* _err) : err(_err) {
          assert(!err.empty());
      }
  
      operator bool() const { return err.empty(); }
  };
  
  #define CHECK_RETURN(cmd) { ReturnType ret = (cmd); if(!ret) return ret; }
  
  using namespace std;
  using namespace v8;
  
  ReturnType readFile(const std::string&amp; filename, std::string&amp; res) {
      res = "";
  
      FILE* f = fopen(filename.c_str(), "r");
      if(!f) return "File '" + filename + "' cannot be opened";
  
      while(!feof(f) &amp;&amp; !ferror(f)) {
          char buffer[1024 * 8];
          size_t s = fread(buffer, 1, sizeof(buffer), f);
          if(s &gt; 0)
              res.append(buffer, buffer + s);
      }
  
      auto err = ferror(f);
      fclose(f);
  
      if(err)
          return "Error while reading file '" + filename + "'";
  
      return true;
  }
  
  
  
  ReturnType execJsFile(const std::string&amp; jsSourceDir, const std::string&amp; extfilename) {
      v8::TryCatch try_catch;
  
      std::string sourceStr;
      CHECK_RETURN(readFile(jsSourceDir + "/" + extfilename, sourceStr));
  
      Local&lt;String&gt; origin = String::NewFromUtf8(Isolate::GetCurrent(), &amp;extfilename[0], String::kNormalString, (int)extfilename.size());
      Local&lt;String&gt; source = String::NewFromUtf8(Isolate::GetCurrent(), &amp;sourceStr[0], String::kNormalString, (int)sourceStr.size());
  
      Local&lt;v8::Script&gt; script = Script::Compile(source, origin);
      if(script.IsEmpty()) {
          assert(try_catch.HasCaught());
          return "JS compile failed: " + jsObjToString(try_catch.Exception());
      }
  
      // Run the script to setup its environment
      Local&lt;Value&gt; result = script-&gt;Run();
      if(result.IsEmpty()) {
          assert(try_catch.HasCaught());
          return "JS script execution failed: " + jsReportExceptionToString(Isolate::GetCurrent(), &amp;try_catch);
      }
  
      return true;
  }
  
  
  ReturnType loadJsGit() {
      V8Isolate isolate;
      v8::Isolate::Scope isolateScope(isolate);
      HandleScope handleScope(isolate);
      Handle&lt;Context&gt; context = Context::New(isolate);
      Context::Scope contextScope(context);
      auto globalObj = context-&gt;Global();
  
      CHECK_RETURN(execJsFile(".", "global.js"));
      CHECK_RETURN(execJsFile(".", "jsgit.js"));
  
      return true;
  }
  
  int main(int argc, char** argv) {
      ReturnType ret = loadJsGit();
      if(!ret) cout &lt;&lt; "error: " &lt;&lt; ret.err &lt;&lt; endl;
  }
  </code></pre>