Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory fault on SBCL (and call for ideas) #1

Open
vindarel opened this issue Jun 4, 2024 · 13 comments
Open

Memory fault on SBCL (and call for ideas) #1

vindarel opened this issue Jun 4, 2024 · 13 comments

Comments

@vindarel
Copy link

vindarel commented Jun 4, 2024

These bindings are excellent and could be big for CL.

As we discussed though, I currently have errors when trying the examples :S

I'll add details, if anyone has an idea, thanks in advance.

I run this:

(in-package :webui)

(defun minimal ()
  (let ((w (webui-new-window)))
    (webui-bind w "my-button"
                (lambda (event)
                  (declare (ignore event))
                  (webui-run w "alert(\"hi\");")))
    (webui-show w "<html>
                   <script src=\"webui.js\"></script>
                   Hello,
                   <button id=\"my-button\">world!</button>
                 </html>")
    (webui-wait)))

(minimal)

Versions

System version

it's old-ish

OS: Linux Mint 20 LTS x86_64 (Ubuntu Focal)
Kernel: 5.4.0-176-generic
gcc 9.4
GLIBC 2.31

Lisp versions

CFFI pulled today

SBCL 2.1.5, 2.4.1 and 2.4.5

CL-USER> (webui::minimal)

Unhandled memory fault at #x7F49D4E04A60.
   [Condition of type SB-SYS:MEMORY-FAULT-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD tid=843809 "repl-thread" RUNNING {100586DD33}>)

Backtrace:
  0: (SB-SYS:MEMORY-FAULT-ERROR #<unused argument> #.(SB-SYS:INT-SAP #X7F49D4E04A60))
  1: ("foreign function: call_into_lisp_")
  2: ("foreign function: funcall2")
  3: ("foreign function: handle_memory_fault_emulation_trap")
  4: ("foreign function: handle_trap")
  5: ("foreign function: #x55FAD404D7B5")
  6: (WEBUI::MINIMAL)

CCL "Version 1.11-r16635 (LinuxX8664)"

CL-USER> (webui::minimal )
The value (:INTERNAL CFFI-CALLBACKS::|WEBUI::WEBUI-BIND-CB|
           WEBUI:WEBUI-BIND) is not of the expected type (AND
                                                          SYMBOL
                                                          (NOT
                                                           (SATISFIES
                                                            CONSTANTP))).
   [Condition of type TYPE-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT-BREAK] Reset this thread
 3: [ABORT] Kill this thread

Backtrace:
  0: (CCL::DEFINE-CALLBACK-FUNCTION #<COMPILED-LEXICAL-CLOSURE (:INTERNAL CFFI-CALLBACKS::|WEBUI::WEBUI-BIND-CB| WEBUI:WEBUI-BIND) #x302002D15A7F> NIL NIL NIL)
      Locals:
        LISP-FUNCTION = #<COMPILED-LEXICAL-CLOSURE (:INTERNAL CFFI-CALLBACKS::|WEBUI::WEBUI-BIND-CB| WEBUI:WEBUI-BIND) #x302002DD947F>
        DOC-STRING = NIL
        WITHOUT-INTERRUPTS = NIL
        INFO = NIL
        NAME = (:INTERNAL CFFI-CALLBACKS::|WEBUI::WEBUI-BIND-CB| WEBUI:WEBUI-BIND)
        TRAMPOLINE = NIL
  1: (WEBUI:WEBUI-BIND 2 "my-button" #<COMPILED-LEXICAL-CLOSURE (:INTERNAL WEBUI::MINIMAL) #x302002D15ABF>)
  2: (WEBUI::MINIMAL)

webui C bindings

I built them with make, the minimal C example works (with a Makefile tweak, see their issues).

@vindarel
Copy link
Author

vindarel commented Jun 4, 2024

Following your idea, this instead of webui-show works:

(webui-show-browser w "<html>
                   <script src=\"webui.js\"></script>
                   Hello,
                   <button id=\"my-button\">world!</button>
                 </html>"
                1)

the 1 is to open a Firefox window (it was a wild guess). I can see it, the button callback works.

but wait… it looks like trying to run it a second time does nothing. No error, no return value, no browser window. I restart the Lisp and I can run it once again.

@garlic0x1
Copy link
Owner

To run it multiple times without issues, you must call webui-destroy, this is demonstrated in call-js-from-lisp.lisp.
I did not include it in the minimal example because the C example does not have it. Maybe I should since it is more likely for a Lisp user to start the window multiple times from a single process.

@garlic0x1
Copy link
Owner

Exported the browser enum, now instead of 1 you can use +webui-any-browser+, or +webui-firefox+

@vindarel
Copy link
Author

vindarel commented Jun 5, 2024

no more luck with webui-destroy :/

I do

(defun minimal ()
  (let ((w (webui-new-window)))
    (webui-bind w "my-button"
                (lambda (event)
                  (declare (ignore event))
                  (webui-run w "alert(\"hi\");")))
    (webui-show-browser w "<html>
                   <script src=\"webui.js\"></script>
                   Hello,
                   <button id=\"my-button\">world!</button>
                 </html>"
                +webui-chromium-based+)   ;; with either Firefox or Chromium
    (webui-wait)
    (webui-destroy w))  ;; <---- destroy
  )

a second call does nothing.

@garlic0x1
Copy link
Owner

I'm not sure, I am able to call this exact function twice in a row, only difference is I used Firefox (no chromium installed)

@fosskers
Copy link

fosskers commented Jul 3, 2024

Given:

(defun run ()
  (let ((w (ui:webui-new-window)))
    (ui:webui-show-browser w "<html>Hello, world!</html>" ui:+webui-firefox+)
    (ui:webui-wait)
    (ui:webui-destroy w)))

then

CL-USER> (webby::run)
; No values

and nothing appears in my browser. Firefox was already open, mind you, and I'm on Wayland with a tiling window manager. Any idea what the issue might be?

@garlic0x1
Copy link
Owner

@fosskers I am not sure, are you able to run the dynamically linked examples in the webui repository?
I am on X11, Gnome, Arch, and WebUI built from source, I will test on Wayland and see if that causes any issues.

image

@fosskers
Copy link

fosskers commented Jul 4, 2024

Unfortunately I'm not able to get any windows to appear, either through Firefox or Chromium, and it's not clear why. (run) just hangs without doing anything.

@vindarel
Copy link
Author

vindarel commented Jul 4, 2024

I have to mention that CLOG frame allows me to have a webview, easily. It is based on webview.h (and not tied to CLOG nor to CL).

@fosskers
Copy link

fosskers commented Jul 4, 2024

I should perhaps mention that I'm on 2.5.0+beta.1 of webui.

@garlic0x1
Copy link
Owner

@fosskers I was playing around with this today, the AUR package builds webui with make WEBUI_USE_TLS=1 which allows me to recreate this issue, if you do the default make target things will work fine. I will see if I can fix this in a better way, but changing your PKGBUILD or building from source is a workaround for now.

@garlic0x1
Copy link
Owner

Same issue in the webui examples, I submitted an issue there webui-dev/webui#454

@fosskers
Copy link

Thanks! I'll test it again locally today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants