dudik / blockit

WebKitGTK adblock extension with Brave's Rust-based adblock engine for backend.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Broken on obsd

sdsddsd1 opened this issue · comments

Hello,
I try to get blockit running on an OpenBSD -current machine. I opened 2 urls after another. The actual webpage is not rendered. It errors out with the following:

~/.cargo/bin $ RUST_BACKTRACE=full ./adblock-rust-server  
init-done
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /home/claudia/.cargo/registry/src/github.com-1ecc6299db9ec823/adblock-rust-server-0.1.0/src/main.rs:33:58
stack backtrace:
   0:       0x416d24a90c - <unknown>
   1:       0x416d279bbd - <unknown>
   2:       0x416d245ac4 - <unknown>
   3:       0x416d25db34 - <unknown>
   4:       0x416d25d721 - <unknown>
   5:       0x416d25e14c - <unknown>
   6:       0x416d24ae62 - <unknown>
   7:       0x416d24aa40 - <unknown>
   8:       0x416d25dcf6 - <unknown>
   9:       0x416d27bd40 - <unknown>
  10:       0x416d27bc98 - <unknown>
  11:       0x416d0c13fc - <unknown>
  12:       0x416d0bc9e5 - <unknown>
  13:       0x416d0c300e - <unknown>
  14:       0x416d2639ed - <unknown>
  15:       0x443dd62e11 - <unknown>
  16:       0x446813f63a - <unknown>
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }', /home/claudia/.cargo/registry/src/github.com-1ecc6299db9ec823/adblock-rust-server-0.1.0/src/main.rs:52:38
stack backtrace:
   0:       0x416d24a90c - <unknown>
   1:       0x416d279bbd - <unknown>
   2:       0x416d245ac4 - <unknown>
   3:       0x416d25db34 - <unknown>
   4:       0x416d25d721 - <unknown>
   5:       0x416d25e14c - <unknown>
   6:       0x416d24ae98 - <unknown>
   7:       0x416d24aa40 - <unknown>
   8:       0x416d25dcf6 - <unknown>
   9:       0x416d27bd40 - <unknown>
  10:       0x416d277e86 - <unknown>
  11:       0x416d0c132c - <unknown>
  12:       0x416d0bc9e5 - <unknown>
  13:       0x416d0c300e - <unknown>
  14:       0x416d2639ed - <unknown>
  15:       0x443dd62e11 - <unknown>
  16:       0x446813f63a - <unknown>

Hi, I'm trying to reproduce this bug, but I'm not even able to compile blockit on OpenBSD:

cc blockit.c -o blockit.so -fPIC -shared `pkg-config --cflags webkit2gtk-4.0 webkit2gtk-web-extension-4.0 glib-2.0 gio-2.0` -O2 -pipe
blockit.c:15:2: warning: implicit declaration of function 'g_uri_split' is
      invalid in C99 [-Wimplicit-function-declaration]
        g_uri_split(request_uri, G_URI_FLAGS_NONE, NULL, NULL, NULL, NUL...
        ^
blockit.c:15:27: error: use of undeclared identifier 'G_URI_FLAGS_NONE'
        g_uri_split(request_uri, G_URI_FLAGS_NONE, NULL, NULL, NULL, NUL...
                                 ^
blockit.c:72:3: warning: ignoring return value of function declared with
      'warn_unused_result' attribute [-Wunused-result]
                jsc_context_evaluate(js_context, res->str, -1);
                ^~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings and 1 error generated.
*** Error 1 in /home/user/Desktop/blockit (Makefile:12 'blockit.so')

Did you have to change anything in the Makefile? I don't use OpenBSD, so it might be a silly mistake on my part.

I have a working webkit browser working. The warning is generated but its building through. This is with a plain make file and no CFLAGS or CC changed.

pkg_add webkitgtk4 surf
~ $ cd blockit/                                                                                                                                       
~/blockit $ make clean
rm -f blockit.so
~/blockit $ make
cc blockit.c -o blockit.so -fPIC -shared `pkg-config --cflags webkit2gtk-4.0 webkit2gtk-web-extension-4.0 glib-2.0 gio-2.0` -O2 -pipe 
blockit.c:70:3: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
                jsc_context_evaluate(js_context, res->str, -1);
                ^~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

But I am running -current. The latest development snapshot.

sysupgrade -s

So after spending some time trying to make it work with glib socket functions I just tried using vanilla C functions and it seems to work? I have no idea why. Could you please try out the socket branch and tell me if it fixed the problem? Thanks.

This does solve the crashes and it seems to work! Adblock tests show sucksessfully results.
And visually ads are gone! Thanks for your work! Webkit runs now almost at a reasonable speed on obsd :p.
If there is more testing to do, let me know.

I merged the changes into the main branch. I still have to add some features into blockit and adblock-rust-server, so it would be great if you could occasionally download the latest versions and report any problems. Thank you!

Ahoi,
after latest commit there seems to be someting wrong with the Makefile.

/tmp/blockit $ make
cc  -o blockit.so -fPIC -shared `pkg-config --cflags webkit2gtk-4.0 webkit2gtk-web-extension-4.0 glib-2.0 gio-2.0` -O3 -pipe -march=native
cc: error: no input files
*** Error 1 in /tmp/blockit (Makefile:12 'blockit.so'

Also I cannot build adblock-rust-server with libressl 3.2.2 . Unsure if you can something about that or a crate has to be updated.

error: failed to run custom build command for `openssl-sys v0.9.61`                                                                                                                                                                                                             

Caused by:                                                                                                                                                                                      
  process didn't exit successfully: `/tmp/cargo-install5PSeQz/release/build/openssl-sys-6a87511a5c24ffec/build-script-main` (exit code: 101)                                                                                                                                    
  --- stdout                                                                                                                                                                                            
  cargo:rustc-cfg=const_fn                                                                                                                                                                                                                                      
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_OPENBSD_OPENSSL_LIB_DIR                                                                                                                                                                                                             
  X86_64_UNKNOWN_OPENBSD_OPENSSL_LIB_DIR unset                                                                                                                                                                                                                                  
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR                                                                                                                                                                                                                                    
  OPENSSL_LIB_DIR unset                                                                                                                                                                                                                             
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_OPENBSD_OPENSSL_INCLUDE_DIR                                                                                                                                                                                                         
  X86_64_UNKNOWN_OPENBSD_OPENSSL_INCLUDE_DIR unset                                                                                                                                                                                                                              
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR                                                                                                                                                                                                                                
  OPENSSL_INCLUDE_DIR unset                                                                                                                                                                                                                                         
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_OPENBSD_OPENSSL_DIR                                                                                                                                                                                                                 
  X86_64_UNKNOWN_OPENBSD_OPENSSL_DIR unset                                                                                                                                                                                                                                      
  cargo:rerun-if-env-changed=OPENSSL_DIR                                                                                                                                                                                                                                        
  OPENSSL_DIR unset                                                                                                                                                                                                                 
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG                                                                                                                                                                                                                              
  cargo:rerun-if-env-changed=PKG_CONFIG                                                                                                                                                                                                                                         
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-openbsd
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_openbsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-openbsd
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_openbsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-openbsd
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_openbsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=SYSROOT
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rustc-link-lib=ssl
  cargo:rustc-link-lib=crypto
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=OPENSSL_STATIC
  cargo:rerun-if-env-changed=OPENSSL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-openbsd
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_openbsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-openbsd
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_openbsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-openbsd
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_openbsd
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  OPT_LEVEL = Some("3")
  TARGET = Some("x86_64-unknown-openbsd")
  HOST = Some("x86_64-unknown-openbsd")
  CC_x86_64-unknown-openbsd = None
  CC_x86_64_unknown_openbsd = None
  HOST_CC = None
  CC = None
  CFLAGS_x86_64-unknown-openbsd = None
  CFLAGS_x86_64_unknown_openbsd = None
  HOST_CFLAGS = None
  CFLAGS = Some("-O3 -pipe -march=native")
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-O3" "-pipe" "-march=native" "-E" "build/expando.c"
  exit code: 0
  cargo:rustc-cfg=osslconf="OPENSSL_NO_BUF_FREELISTS"
  cargo:rustc-cfg=osslconf="OPENSSL_NO_COMP"
  cargo:rustc-cfg=osslconf="OPENSSL_NO_KRB5"
  cargo:rustc-cfg=osslconf="OPENSSL_NO_PSK"
  cargo:rustc-cfg=osslconf="OPENSSL_NO_RFC3779"
argo:rustc-cfg=osslconf="OPENSSL_NO_SRP"
  cargo:rustc-cfg=osslconf="OPENSSL_NO_SSL3_METHOD"
  cargo:conf=OPENSSL_NO_BUF_FREELISTS,OPENSSL_NO_COMP,OPENSSL_NO_KRB5,OPENSSL_NO_PSK,OPENSSL_NO_RFC3779,OPENSSL_NO_SRP,OPENSSL_NO_SSL3_M
  cargo:rustc-cfg=libressl
  cargo:rustc-cfg=libressl251
  cargo:rustc-cfg=libressl261
  cargo:rustc-cfg=libressl270
  cargo:rustc-cfg=libressl271
  cargo:rustc-cfg=libressl273
  cargo:rustc-cfg=libressl280
  cargo:rustc-cfg=libressl281
  cargo:rustc-cfg=libressl291
  cargo:rustc-cfg=libressl321
  cargo:libressl_version_number=3030200f

  --- stderr
  thread 'main' panicked at '

  This crate is only compatible with OpenSSL 1.0.1 through 1.1.1, or LibreSSL 2.5
  through 3.3.1, but a different version of OpenSSL was found. The build is now aborting
  due to this version mismatch.

  ', /home/claudia/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.61/build/main.rs:271:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `adblock-rust-server v0.2.0`, intermediate artifacts can be found at `/tmp/cargo-install5PSeQz`

Caused by:
  build failed

The Makefile problem should be fixed, but I wasn't able to reproduce the problem with building ablock-rust-server. However I'm using the 3.3.1 version of LibreSSL. But I'm also testing on -current, so I'm not completely sure why the versions differ. I updated the adblock crate a few days ago so maybe it has something to do with that?

The latest commit fixes the build on my end. 👍

~ $ openssl version                                                                                                                                   
LibreSSL 3.3.2

When using -current, the base system gets updated with sysupgrade -sto the latest snapshot and pkg_add -uupdates the installed 3rd party packages.
Libressl 3.3.2 seems to get introduced somewhat recently. https://www.openbsd.org/plus.html -> search for
libre.
Luckily I have build adblock-rust-server before the change and the binary still works.