brave-experiments / ad-block

Ad block engine used in the Brave browser for ABP filter syntax based lists like EasyList.
https://www.brave.com
Mozilla Public License 2.0
240 stars 95 forks source link

Ad-block stopped working after update #117

Open ancodeUDW opened 6 years ago

ancodeUDW commented 6 years ago

Hello. I am using brave ad-block in a project, and it was working properly until yesterday that I updated it. My operative system is Ubuntu 16.04.4 LTS.

After several hours looking what was wrong, I found that there was an update in ad-block, bloom-filter-cpp and hashset-cpp that makes it fails to compile when you do an npm install or an electron-rebuild.

I managed to figure out that bloom-filter-cpp@1.18 and hashset-cpp@2.0.1 can be compiled whitout problem, however later versions won't work. However, I could not force ad-block to be installed with those versions due the "preinstall" script installing the last versions anyway, ad-block wont finish the install and wont work.

In order to fix the issue, I did a fork of the project so I could force the "preinstall" script to install the versions that do work, however, after doing that, if well both modules can be installed properly, it still breaks at the end of the installation. The only way i had to fix that is to revert back to commit 5377ddea390a0641d99556e0cf9d9c15b8ef275c, in where, if I force bloom-filter-cpp@1.18 and hashset-cpp@2.0.1, it compiles and works again.

The error message that gives me after doing npm install is the following:

ad-block@4.1.1 preinstall /git/addaps_desktop_electron_0.5/node_modules/ad-block

npm install bloom-filter-cpp && npm install hashset-cpp

npm WARN invalid config loglevel="notice"

bloom-filter-cpp@1.2.0 install /git/addaps_desktop_electron_0.5/node_modules/ad-block/node_modules/bloom-filter-cpp node-gyp rebuild

make: se entra en el directorio '/git/addaps_desktop_electron_0.5/node_modules/ad-block/node_modules/bloom-filter-cpp/build' CXX(target) Release/obj.target/bloom-filter-cpp/addon.o CXX(target) Release/obj.target/bloom-filter-cpp/BloomFilterWrap.o ../BloomFilterWrap.cpp: In static member function 'static void BloomFilterWrap::BloomFilterWrap::Add(const v8::FunctionCallbackInfov8::Value&)': ../BloomFilterWrap.cpp:72:53: error: no matching function for call to 'v8::String::Utf8Value::Utf8Value(v8::Isolate&, v8::Localv8::String)' String::Utf8Value str(isolate, args[0]->ToString()); ^ In file included from /home/developer/.node-gyp/8.9.3/include/node/node.h:63:0, from ../BloomFilterWrap.h:9, from ../BloomFilterWrap.cpp:6: /home/developer/.node-gyp/8.9.3/include/node/v8.h:2764:14: note: candidate: v8::String::Utf8Value::Utf8Value(v8::Localv8::Value) explicit Utf8Value(Localv8::Value obj); ^ /home/developer/.node-gyp/8.9.3/include/node/v8.h:2764:14: note: candidate expects 1 argument, 2 provided ../BloomFilterWrap.cpp: In static member function 'static void BloomFilterWrap::BloomFilterWrap::Exists(const v8::FunctionCallbackInfov8::Value&)': ../BloomFilterWrap.cpp:81:53: error: no matching function for call to 'v8::String::Utf8Value::Utf8Value(v8::Isolate&, v8::Localv8::String)' String::Utf8Value str(isolate, args[0]->ToString()); ^ In file included from /home/developer/.node-gyp/8.9.3/include/node/node.h:63:0, from ../BloomFilterWrap.h:9, from ../BloomFilterWrap.cpp:6: /home/developer/.node-gyp/8.9.3/include/node/v8.h:2764:14: note: candidate: v8::String::Utf8Value::Utf8Value(v8::Localv8::Value) explicit Utf8Value(Localv8::Value obj); ^ /home/developer/.node-gyp/8.9.3/include/node/v8.h:2764:14: note: candidate expects 1 argument, 2 provided bloom-filter-cpp.target.mk100 fallo en las instrucciones para el objetivo 'Release/obj.target/bloom-filter-cpp/BloomFilterWrap.o' make: *** [Release/obj.target/bloom-filter-cpp/BloomFilterWrap.o] Error 1 make: se sale del directorio '/git/addaps_desktop_electron_0.5/node_modules/ad-block/node_modules/bloom-filter-cpp/build' gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/git/addaps_desktop_electron_0.5/node_modules/npm/node_modules/node-gyp/lib/build.js:285:23) gyp ERR! stack at emitTwo (events.js:126:13) gyp ERR! stack at ChildProcess.emit (events.js:214:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12) gyp ERR! System Linux 4.14.0-041400-lowlatency gyp ERR! command "/home/developer/.nvm/versions/node/v8.9.3/bin/node" "/git/addaps_desktop_electron_0.5/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /git/addaps_desktop_electron_0.5/node_modules/ad-block/node_modules/bloom-filter-cpp gyp ERR! node -v v8.9.3 gyp ERR! node-gyp -v v3.6.0 gyp ERR! not ok npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! bloom-filter-cpp@1.2.0 install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the bloom-filter-cpp@1.2.0 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/developer/.npm/_logs/2018-06-28T06_58_32_623Z-debug.log npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-win@2.1.1 (node_modules/7zip-bin-win): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 7zip-bin-win@2.1.1: wanted {"os":"win32","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-mac@1.0.1 (node_modules/7zip-bin-mac): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 7zip-bin-mac@1.0.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! ad-block@4.1.1 preinstall: npm install bloom-filter-cpp && npm install hashset-cpp npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the ad-block@4.1.1 preinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/developer/.npm/_logs/2018-06-28T06_58_34_831Z-debug.log

If you force Bloom-filter-cpp to be version 1.1.8, hashset-cpp and ad-block returns similar errors by their own, and, as I mention, the only way I was able to make it work was forcing also hashset-ccp to be 2.0.1 and using ad-block with the commit 5377ddea390a0641d99556e0cf9d9c15b8ef275c

Thank you

bsclifton commented 6 years ago

Hi @ancodeUDW - I recently ran into this too... I was able to resolve the issue by updating to node version 10.5.0 (the latest; not LTS). I tried LTS and it didn't work either

Can you try updating node to see if that works?

ancodeUDW commented 6 years ago

Hello, @bsclifton

unfortunately, I cannot update Node version, due the project being an electron project, so I am forced to keep the same version that electron uses (if not it won't work).

mailtokartik1 commented 6 years ago

Same here, electron application and facing a lot of problems.

mailtokartik1 commented 6 years ago

any updates on this, we need a fix for this

bsclifton commented 6 years ago

@ancodeUDW the version of node used by electron shouldn't matter, right? Since node is compiled into electron. Are you building electron from source?

ex: Brave is an electron app (well, we forked electron and diverged) which is using Node 7.9.0. But locally, I have node v8.11.2 installed. Using nvm, I switched to the latest (10.5.0) and was able to get it working

cjroebuck commented 6 years ago

With node 10.6.0 I can't install ad-block (on osx and ubuntu 16.04):

osx:

../BloomFilterWrap.cpp:72:21: error: no matching constructor for initialization of
      'String::Utf8Value'
  String::Utf8Value str(isolate, args[0]->ToString());
                    ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cjr/.node-gyp/iojs-1.6.11/deps/v8/include/v8.h:2624:14: note: candidate     constructor not
      viable: requires single argument 'obj', but 2 arguments were provided
    explicit Utf8Value(Local<v8::Value> obj);
             ^
/Users/cjr/.node-gyp/iojs-1.6.11/deps/v8/include/v8.h:2631:5: note: candidate     constructor not viable:
      requires 1 argument, but 2 were provided
    Utf8Value(const Utf8Value&) = delete;
    ^
../BloomFilterWrap.cpp:81:21: error: no matching constructor for initialization of
      'String::Utf8Value'
  String::Utf8Value str(isolate, args[0]->ToString());
                    ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/cjr/.node-gyp/iojs-1.6.11/deps/v8/include/v8.h:2624:14: note: candidate     constructor not
      viable: requires single argument 'obj', but 2 arguments were provided
    explicit Utf8Value(Local<v8::Value> obj);
             ^
/Users/cjr/.node-gyp/iojs-1.6.11/deps/v8/include/v8.h:2631:5: note: candidate     constructor not viable:
      requires 1 argument, but 2 were provided
    Utf8Value(const Utf8Value&) = delete;
    ^
2 errors generated.
make: *** [Release/obj.target/bloom-filter-cpp/BloomFilterWrap.o] Error 1

and ubuntu:

../BloomFilterWrap.cpp: In static member function 'static void     BloomFilterWrap::BloomFilterWrap::Add(const v8::FunctionCallbackInfo<v8::Value>&)    ':
../BloomFilterWrap.cpp:72:53: error: no matching function for call to     'v8::String::Utf8Value::Utf8Value(v8::Isolate*&, v8::Local<v8::String>)'
   String::Utf8Value str(isolate, args[0]->ToString());
                                                     ^
In file included from /home/ubuntu/.node-gyp/iojs-1.6.11/src/node.h:42:0,
                 from ../BloomFilterWrap.h:9,
                 from ../BloomFilterWrap.cpp:6:
/home/ubuntu/.node-gyp/iojs-1.6.11/deps/v8/include/v8.h:2624:14: note: candidate:     v8::String::Utf8Value::Utf8Value(v8::Local<v8::Value>)
     explicit Utf8Value(Local<v8::Value> obj);
              ^
/home/ubuntu/.node-gyp/iojs-1.6.11/deps/v8/include/v8.h:2624:14: note:       candidate expects 1 argument, 2 provided
../BloomFilterWrap.cpp: In static member function 'static void     BloomFilterWrap::BloomFilterWrap::Exists(const     v8::FunctionCallbackInfo<v8::Value>&)':
../BloomFilterWrap.cpp:81:53: error: no matching function for call to     'v8::String::Utf8Value::Utf8Value(v8::Isolate*&, v8::Local<v8::String>)'
   String::Utf8Value str(isolate, args[0]->ToString());
                                                     ^
In file included from /home/ubuntu/.node-gyp/iojs-1.6.11/src/node.h:42:0,
                 from ../BloomFilterWrap.h:9,
                 from ../BloomFilterWrap.cpp:6:
/home/ubuntu/.node-gyp/iojs-1.6.11/deps/v8/include/v8.h:2624:14: note: candidate:     v8::String::Utf8Value::Utf8Value(v8::Local<v8::Value>)
     explicit Utf8Value(Local<v8::Value> obj);
              ^
/home/ubuntu/.node-gyp/iojs-1.6.11/deps/v8/include/v8.h:2624:14: note:       candidate expects 1 argument, 2 provided
bloom-filter-cpp.target.mk:99: recipe for target     'Release/obj.target/bloom-filter-cpp/BloomFilterWrap.o' failed
make: *** [Release/obj.target/bloom-filter-cpp/BloomFilterWrap.o] Error 1
cjroebuck commented 6 years ago

It would be great if we could downgrade to use an older version of adblock to avoid this issue until it is fixed.

The problem, however, is that I believe the npm preinstall script in adblock always blindly installs the latest version of bloom-filter-cpp and hashset-cpp regardless of the version of adblock.

package.json:

...

"preinstall": "npm install bloom-filter-cpp && npm install hashset-cpp",

....
mailtokartik1 commented 6 years ago

@cjroebuck one solution would be to fork the project and make the changes. However, somehow, I haven't been able to successfully run electron-rebuild uptil now.

bsclifton commented 6 years ago

@cjroebuck with the proper version of node now installed, can you please try deleting your ~/.node-gyp/ folder? I suspect it has corrupt files from before

ancodeUDW commented 6 years ago

@cjroebuck @mailtokartik1 When I faced this problem, I did a fork and I tried to force bloom-filter-cpp and hashset-cpp to the last working version

(as @cjroebuck mentions, it doesn't matter the version that its stated in the package.json or in the package-lock.json, the build script has a hardcoded "npm install bloom-filter && npm install hashset-cpp", so in my fork I had to force the version in there as well).

However, it kept giving troubles internally because it looks like the updates from those 2 files were also added to the adblock core itself, so the only way I could make it work was to not only force those modules to the last working version, but also to revert to a early commit that doesn't have those changes as well.

@bsclifton so far I know electron's node matters, because in the end, when we will do the electron release, the program will be installed in computers that do not have node, and electron uses its own version, so its important to keep modules compatibles with it. Update the node inside electron is not recommended, so instead its a matter of waiting until electron updates their project. For this reason, we use electron-rebuild in my project, that it ensures all native modules are compiled to electron's node, ignoring the external node we might have in our computer. However, I will try to not to force electron node and to install the last node as you suggested, to see what happens, whenever I have time.