Unverified Commit c9caae47 by Mohamed Akram Committed by GitHub

Fix worker threads crash (#1367)

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