Unverified Commit c9caae47 by Mohamed Akram Committed by GitHub

Fix worker threads crash (#1367)

parent 6e250c64
...@@ -26,3 +26,4 @@ local.env ...@@ -26,3 +26,4 @@ local.env
.eslintrc.js .eslintrc.js
setup.sh setup.sh
/build-tmp-napi-v3 /build-tmp-napi-v3
/build-tmp-napi-v6
...@@ -75,7 +75,7 @@ matrix: ...@@ -75,7 +75,7 @@ matrix:
# electron Linux # electron Linux
- os: linux - os: linux
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="8.2.0" env: NODE_VERSION="12.13.0" ELECTRON_VERSION="8.2.0"
dist: trusty dist: trusty
addons: addons:
apt: apt:
...@@ -83,7 +83,7 @@ matrix: ...@@ -83,7 +83,7 @@ matrix:
packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] packages: [ 'clang-3.5', 'libstdc++-4.9-dev']
- os: linux - os: linux
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="8.1.0" env: NODE_VERSION="12.13.0" ELECTRON_VERSION="8.1.0"
dist: trusty dist: trusty
addons: addons:
apt: apt:
...@@ -91,7 +91,7 @@ matrix: ...@@ -91,7 +91,7 @@ matrix:
packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] packages: [ 'clang-3.5', 'libstdc++-4.9-dev']
- os: linux - os: linux
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="8.0.0" env: NODE_VERSION="12.13.0" ELECTRON_VERSION="8.0.0"
dist: trusty dist: trusty
addons: addons:
apt: apt:
...@@ -99,7 +99,7 @@ matrix: ...@@ -99,7 +99,7 @@ matrix:
packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] packages: [ 'clang-3.5', 'libstdc++-4.9-dev']
- os: linux - os: linux
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="7.2.0" env: NODE_VERSION="12.8.1" ELECTRON_VERSION="7.2.0"
dist: trusty dist: trusty
addons: addons:
apt: apt:
...@@ -107,7 +107,7 @@ matrix: ...@@ -107,7 +107,7 @@ matrix:
packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] packages: [ 'clang-3.5', 'libstdc++-4.9-dev']
- os: linux - os: linux
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="7.1.0" env: NODE_VERSION="12.8.1" ELECTRON_VERSION="7.1.0"
dist: trusty dist: trusty
addons: addons:
apt: apt:
...@@ -115,7 +115,7 @@ matrix: ...@@ -115,7 +115,7 @@ matrix:
packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] packages: [ 'clang-3.5', 'libstdc++-4.9-dev']
- os: linux - os: linux
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="7.0.0" env: NODE_VERSION="12.8.1" ELECTRON_VERSION="7.0.0"
dist: trusty dist: trusty
addons: addons:
apt: apt:
...@@ -123,7 +123,7 @@ matrix: ...@@ -123,7 +123,7 @@ matrix:
packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] packages: [ 'clang-3.5', 'libstdc++-4.9-dev']
- os: linux - os: linux
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="6.1.0" env: NODE_VERSION="12.4.0" ELECTRON_VERSION="6.1.0"
dist: trusty dist: trusty
addons: addons:
apt: apt:
...@@ -131,7 +131,7 @@ matrix: ...@@ -131,7 +131,7 @@ matrix:
packages: [ 'clang-3.5', 'libstdc++-4.9-dev'] packages: [ 'clang-3.5', 'libstdc++-4.9-dev']
- os: linux - os: linux
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="6.0.0" env: NODE_VERSION="12.4.0" ELECTRON_VERSION="6.0.0"
dist: trusty # needed for libc6 / 'version `GLIBC_2.17` not found' error on precise dist: trusty # needed for libc6 / 'version `GLIBC_2.17` not found' error on precise
addons: addons:
apt: apt:
...@@ -140,28 +140,28 @@ matrix: ...@@ -140,28 +140,28 @@ matrix:
# electron MacOs # electron MacOs
- os: osx - os: osx
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="8.2.0" env: NODE_VERSION="12.13.0" ELECTRON_VERSION="8.2.0"
- os: osx - os: osx
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="8.1.0" env: NODE_VERSION="12.13.0" ELECTRON_VERSION="8.1.0"
- os: osx - os: osx
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="8.0.0" env: NODE_VERSION="12.13.0" ELECTRON_VERSION="8.0.0"
- os: osx - os: osx
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="7.2.0" env: NODE_VERSION="12.8.1" ELECTRON_VERSION="7.2.0"
- os: osx - os: osx
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="7.1.0" env: NODE_VERSION="12.8.1" ELECTRON_VERSION="7.1.0"
- os: osx - os: osx
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="7.0.0" env: NODE_VERSION="12.8.1" ELECTRON_VERSION="7.0.0"
- os: osx - os: osx
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="6.1.0" env: NODE_VERSION="12.4.0" ELECTRON_VERSION="6.1.0"
- os: osx - os: osx
compiler: clang compiler: clang
env: NODE_VERSION="12" ELECTRON_VERSION="6.0.0" env: NODE_VERSION="12.4.0" ELECTRON_VERSION="6.0.0"
env: env:
global: global:
......
...@@ -21,88 +21,88 @@ environment: ...@@ -21,88 +21,88 @@ environment:
- nodejs_version: 14 - nodejs_version: 14
platform: x86 platform: x86
# electron # electron
- nodejs_version: 12 - nodejs_version: 12.13.0
platform: x64 platform: x64
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 8.2.0 NODE_RUNTIME_VERSION: 8.2.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.13.0
platform: x86 platform: x86
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 8.2.0 NODE_RUNTIME_VERSION: 8.2.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.13.0
platform: x64 platform: x64
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 8.1.0 NODE_RUNTIME_VERSION: 8.1.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.13.0
platform: x86 platform: x86
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 8.1.0 NODE_RUNTIME_VERSION: 8.1.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.13.0
platform: x64 platform: x64
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 8.0.0 NODE_RUNTIME_VERSION: 8.0.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.13.0
platform: x86 platform: x86
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 8.0.0 NODE_RUNTIME_VERSION: 8.0.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.8.1
platform: x64 platform: x64
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 7.2.0 NODE_RUNTIME_VERSION: 7.2.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.8.1
platform: x86 platform: x86
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 7.2.0 NODE_RUNTIME_VERSION: 7.2.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.8.1
platform: x64 platform: x64
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 7.1.0 NODE_RUNTIME_VERSION: 7.1.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.8.1
platform: x86 platform: x86
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 7.1.0 NODE_RUNTIME_VERSION: 7.1.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.8.1
platform: x64 platform: x64
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 7.0.0 NODE_RUNTIME_VERSION: 7.0.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.8.1
platform: x86 platform: x86
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 7.0.0 NODE_RUNTIME_VERSION: 7.0.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.4.0
platform: x64 platform: x64
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 6.1.0 NODE_RUNTIME_VERSION: 6.1.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.4.0
platform: x86 platform: x86
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 6.1.0 NODE_RUNTIME_VERSION: 6.1.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.4.0
platform: x64 platform: x64
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 6.0.0 NODE_RUNTIME_VERSION: 6.0.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
- nodejs_version: 12 - nodejs_version: 12.4.0
platform: x86 platform: x86
NODE_RUNTIME: electron NODE_RUNTIME: electron
NODE_RUNTIME_VERSION: 6.0.0 NODE_RUNTIME_VERSION: 6.0.0
TOOLSET_ARGS: --dist-url=https://electronjs.org/headers TOOLSET_ARGS: --dist-url=https://electronjs.org/headers
os: Visual Studio 2015 image: Visual Studio 2017
install: install:
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
"remote_path": "./{name}/v{version}/{toolset}/", "remote_path": "./{name}/v{version}/{toolset}/",
"package_name": "napi-v{napi_build_version}-{platform}-{arch}.tar.gz", "package_name": "napi-v{napi_build_version}-{platform}-{arch}.tar.gz",
"napi_versions": [ "napi_versions": [
3 3,
6
] ]
}, },
"contributors": [ "contributors": [
...@@ -40,7 +41,7 @@ ...@@ -40,7 +41,7 @@
"url": "git://github.com/mapbox/node-sqlite3.git" "url": "git://github.com/mapbox/node-sqlite3.git"
}, },
"dependencies": { "dependencies": {
"node-addon-api": "2.0.0", "node-addon-api": "^3.0.0",
"node-pre-gyp": "^0.11.0" "node-pre-gyp": "^0.11.0"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -4,25 +4,22 @@ SET EL=0 ...@@ -4,25 +4,22 @@ SET EL=0
ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %~f0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ECHO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %~f0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IF /I "%msvs_toolset%"=="" ECHO msvs_toolset unset, defaulting to 14 && SET msvs_toolset=14 IF /I "%msvs_version%"=="" ECHO msvs_version unset, defaulting to 2017 && SET msvs_version=2017
IF /I "%msvs_version%"=="" ECHO msvs_version unset, defaulting to 2015 && SET msvs_version=2015
SET PATH=%CD%;%PATH% SET PATH=%CD%;%PATH%
IF "%msvs_toolset%"=="12" SET msvs_version=2013
IF NOT "%NODE_RUNTIME%"=="" SET "TOOLSET_ARGS=%TOOLSET_ARGS% --runtime=%NODE_RUNTIME%" IF NOT "%NODE_RUNTIME%"=="" SET "TOOLSET_ARGS=%TOOLSET_ARGS% --runtime=%NODE_RUNTIME%"
IF NOT "%NODE_RUNTIME_VERSION%"=="" SET "TOOLSET_ARGS=%TOOLSET_ARGS% --target=%NODE_RUNTIME_VERSION%" IF NOT "%NODE_RUNTIME_VERSION%"=="" SET "TOOLSET_ARGS=%TOOLSET_ARGS% --target=%NODE_RUNTIME_VERSION%"
ECHO APPVEYOR^: %APPVEYOR% ECHO APPVEYOR^: %APPVEYOR%
ECHO nodejs_version^: %nodejs_version% ECHO nodejs_version^: %nodejs_version%
ECHO platform^: %platform% ECHO platform^: %platform%
ECHO msvs_toolset^: %msvs_toolset%
ECHO msvs_version^: %msvs_version% ECHO msvs_version^: %msvs_version%
ECHO TOOLSET_ARGS^: %TOOLSET_ARGS% ECHO TOOLSET_ARGS^: %TOOLSET_ARGS%
ECHO activating VS command prompt ECHO activating VS command prompt
:: NOTE this call makes the x64 -> X64 :: NOTE this call makes the x64 -> X64
IF /I "%platform%"=="x64" ECHO x64 && CALL "C:\Program Files (x86)\Microsoft Visual Studio %msvs_toolset%.0\VC\vcvarsall.bat" amd64 IF /I "%platform%"=="x64" ECHO x64 && CALL "C:\Program Files (x86)\Microsoft Visual Studio\%msvs_version%\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
IF /I "%platform%"=="x86" ECHO x86 && CALL "C:\Program Files (x86)\Microsoft Visual Studio %msvs_toolset%.0\VC\vcvarsall.bat" x86 IF /I "%platform%"=="x86" ECHO x86 && CALL "C:\Program Files (x86)\Microsoft Visual Studio\%msvs_version%\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
IF %ERRORLEVEL% NEQ 0 GOTO ERROR IF %ERRORLEVEL% NEQ 0 GOTO ERROR
ECHO using compiler^: && CALL cl ECHO using compiler^: && CALL cl
......
...@@ -7,9 +7,6 @@ ...@@ -7,9 +7,6 @@
using namespace node_sqlite3; using namespace node_sqlite3;
Napi::FunctionReference Backup::constructor;
Napi::Object Backup::Init(Napi::Env env, Napi::Object exports) { Napi::Object Backup::Init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env); Napi::HandleScope scope(env);
...@@ -24,9 +21,6 @@ Napi::Object Backup::Init(Napi::Env env, Napi::Object exports) { ...@@ -24,9 +21,6 @@ Napi::Object Backup::Init(Napi::Env env, Napi::Object exports) {
InstanceAccessor("retryErrors", &Backup::RetryErrorGetter, &Backup::RetryErrorSetter), InstanceAccessor("retryErrors", &Backup::RetryErrorGetter, &Backup::RetryErrorSetter),
}); });
constructor = Napi::Persistent(t);
constructor.SuppressDestruct();
exports.Set("Backup", t); exports.Set("Backup", t);
return exports; return exports;
} }
......
...@@ -93,8 +93,6 @@ namespace node_sqlite3 { ...@@ -93,8 +93,6 @@ namespace node_sqlite3 {
*/ */
class Backup : public Napi::ObjectWrap<Backup> { class Backup : public Napi::ObjectWrap<Backup> {
public: public:
static Napi::FunctionReference constructor;
static Napi::Object Init(Napi::Env env, Napi::Object exports); static Napi::Object Init(Napi::Env env, Napi::Object exports);
struct Baton { struct Baton {
......
#include <string.h> #include <string.h>
#include <napi.h>
#include "macros.h" #include "macros.h"
#include "database.h" #include "database.h"
...@@ -6,7 +7,9 @@ ...@@ -6,7 +7,9 @@
using namespace node_sqlite3; using namespace node_sqlite3;
#if NAPI_VERSION < 6
Napi::FunctionReference Database::constructor; Napi::FunctionReference Database::constructor;
#endif
Napi::Object Database::Init(Napi::Env env, Napi::Object exports) { Napi::Object Database::Init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env); Napi::HandleScope scope(env);
...@@ -23,8 +26,14 @@ Napi::Object Database::Init(Napi::Env env, Napi::Object exports) { ...@@ -23,8 +26,14 @@ Napi::Object Database::Init(Napi::Env env, Napi::Object exports) {
InstanceAccessor("open", &Database::OpenGetter, nullptr) InstanceAccessor("open", &Database::OpenGetter, nullptr)
}); });
#if NAPI_VERSION < 6
constructor = Napi::Persistent(t); constructor = Napi::Persistent(t);
constructor.SuppressDestruct(); constructor.SuppressDestruct();
#else
Napi::FunctionReference* constructor = new Napi::FunctionReference();
*constructor = Napi::Persistent(t);
env.SetInstanceData<Napi::FunctionReference>(constructor);
#endif
exports.Set("Database", t); exports.Set("Database", t);
return exports; return exports;
......
...@@ -21,7 +21,9 @@ class Database; ...@@ -21,7 +21,9 @@ class Database;
class Database : public Napi::ObjectWrap<Database> { class Database : public Napi::ObjectWrap<Database> {
public: public:
#if NAPI_VERSION < 6
static Napi::FunctionReference constructor; static Napi::FunctionReference constructor;
#endif
static Napi::Object Init(Napi::Env env, Napi::Object exports); static Napi::Object Init(Napi::Env env, Napi::Object exports);
static inline bool HasInstance(Napi::Value val) { static inline bool HasInstance(Napi::Value val) {
...@@ -29,7 +31,13 @@ public: ...@@ -29,7 +31,13 @@ public:
Napi::HandleScope scope(env); Napi::HandleScope scope(env);
if (!val.IsObject()) return false; if (!val.IsObject()) return false;
Napi::Object obj = val.As<Napi::Object>(); Napi::Object obj = val.As<Napi::Object>();
#if NAPI_VERSION < 6
return obj.InstanceOf(constructor.Value()); return obj.InstanceOf(constructor.Value());
#else
Napi::FunctionReference* constructor =
env.GetInstanceData<Napi::FunctionReference>();
return obj.InstanceOf(constructor->Value());
#endif
} }
struct Baton { struct Baton {
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
using namespace node_sqlite3; using namespace node_sqlite3;
Napi::FunctionReference Statement::constructor;
Napi::Object Statement::Init(Napi::Env env, Napi::Object exports) { Napi::Object Statement::Init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env); Napi::HandleScope scope(env);
...@@ -23,9 +21,6 @@ Napi::Object Statement::Init(Napi::Env env, Napi::Object exports) { ...@@ -23,9 +21,6 @@ Napi::Object Statement::Init(Napi::Env env, Napi::Object exports) {
InstanceMethod("finalize", &Statement::Finalize_), InstanceMethod("finalize", &Statement::Finalize_),
}); });
constructor = Napi::Persistent(t);
constructor.SuppressDestruct();
exports.Set("Statement", t); exports.Set("Statement", t);
return exports; return exports;
} }
......
...@@ -72,8 +72,6 @@ typedef Row Parameters; ...@@ -72,8 +72,6 @@ typedef Row Parameters;
class Statement : public Napi::ObjectWrap<Statement> { class Statement : public Napi::ObjectWrap<Statement> {
public: public:
static Napi::FunctionReference constructor;
static Napi::Object Init(Napi::Env env, Napi::Object exports); static Napi::Object Init(Napi::Env env, Napi::Object exports);
static Napi::Value New(const Napi::CallbackInfo& info); static Napi::Value New(const Napi::CallbackInfo& info);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment