nnicandro / emacs-zmq

Emacs bindings to ØMQ
GNU General Public License v2.0
49 stars 18 forks source link

Error (fatal) on compile and launch, emacs-zmq.dylib, Symbol not found #45

Open ed9w2in6 opened 1 year ago

ed9w2in6 commented 1 year ago

original ticket from: https://github.com/emacs-jupyter/jupyter/issues/469

Hi

I had upgraded to the latest version on melpa (20230608.1856) recently and are now facing this weird error:

Compiling file /Users/<my-name>/.emacs.d/elpa/jupyter-20230608.1504/jupyter-channel-ioloop.el at Mon Jun 19 20:27:59 2023
jupyter-channel-ioloop.el:67:1: Error: Module could not be opened: "/Users/<my-name>/.emacs.d/elpa/zmq-20230608.1856/emacs-zmq.dylib", "dlopen(/Users/<my-name>/.emacs.d/elpa/zmq-20230608.1856/emacs-zmq.dylib, 1): Symbol not found: __ZNKSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strEv
  Referenced from: /Users/<my-name>/.emacs.d/elpa/zmq-20230608.1856/emacs-zmq.dylib
  Expected in: flat namespace

In which the symbol is a mangled version of this object:

❯ c++filt '__ZNKSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strEv'
std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::str() const

After replacing the emacs-zmq.so / emacs-zmq.dylib file with an older one that I have from backup (emacs-zmq-x86_64-apple-darwin17.4.0) have fixed this issue.

Here are the outputs of otool

❯ otool -Lv emacs-zmq.dylib.bak
emacs-zmq.dylib.bak:
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
    time stamp 2 Thu Jan  1 08:00:02 1970
❯ otool -Lv emacs-zmq.so
emacs-zmq.so:
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
    time stamp 2 Thu Jan  1 08:00:02 1970

Maybe the culprit is the version of this shared library (/usr/lib/libSystem.B.dylib)?

System:

OS: macOS Big Sur 11.4 20F71 x86_64
Shell: zsh 5.8
Terminal: kitty 0.28.1
GNU Emacs 28.2
emacs-jupyter 20230608.1504
zmq-20230608.1856

Please let me know if you would need the full log.

ed9w2in6 commented 6 months ago

@nnicandro I had recently update my macOS to latest version 14.4.1 (23E224) and I had noticed the emacs-zmq module linked with /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0) works fine.

I believe we can concluded that this issue is due to version differences as Apple tends to move more stuff into this god module overtime.

Being aware of the this, now I believe a good approach to resolve this ticket is by simply checking if system-type is 'darwin, then the macOS version can be obtained as follows:

(string-trim
   (shell-command-to-string "sw_vers -productVersion")) 

Then based on that information to determine where to prompt user on whether to download pre-built binaries from Github.

grimesdj commented 6 months ago

Hello, I think I'm having a similar issue when attempting to install the emacs-jupyter package through MELPA. When compiling through the package manager, I get the attached error messages. I tried building an older version, 0.10.10, but ran into a similar error when executing "make test" (see below). Any chance that someone can suggest a workaround/solution? Thanks, D

>> make test
emacs -nw -Q -batch -L . -l ert -l zmq-tests.el \
        --eval "(ert-run-tests-batch-and-exit)"
Checking for compatible module binary to download
Downloading https://github.com/dzop/emacs-zmq/releases/download/v0.10.9/emacs-zmq-x86_64-apple-darwin17.4.0.tar.gz
Verifying sha256 signature of emacs-zmq-x86_64-apple-darwin17.4.0.tar.gz
uncompressing emacs-zmq-x86_64-apple-darwin17.4.0.tar.gz...
uncompressing emacs-zmq-x86_64-apple-darwin17.4.0.tar.gz...done
Parsing tar file... 
Parsing tar file...done
Extracting... \ 
Extracting...done
Debugger entered--Lisp error: (file-missing "Opening input file" "No such file or directory" "/Users/derekgrimes/.emacs.d/elpa/emacs-zmq-0.10.10...")
  copy-file("/Users/derekgrimes/.emacs.d/elpa/emacs-zmq-0.10.10..." "/Users/derekgrimes/.emacs.d/elpa/emacs-zmq-0.10.10...")
  zmq--download-module("tags/v0.10.9")
  zmq-load()
  byte-code("\300 \210\301\302!\207" [zmq-load provide zmq] 2)
  require(zmq)
  load-with-code-conversion("/Users/derekgrimes/.emacs.d/elpa/emacs-zmq-0.10.10..." "/Users/derekgrimes/.emacs.d/elpa/emacs-zmq-0.10.10..." nil t)
  command-line-1(("-L" "." "-l" "ert" "-l" "zmq-tests.el" "--eval" "(ert-run-tests-batch-and-exit)"))
  command-line()
  normal-top-level()

make: *** [test] Error 255

jupyter_compile.log`

ed9w2in6 commented 6 months ago

@grimesdj I think you miswrote your comment, you are NOT compiling but just downloading the binary hosted on Github.

To be sure that you are facing the same issue, first check the linked libraries of emacs-zmq.dylib by doing otool -Lv emacs-zmq.dylib, then also check your macOS version.

If your downloaded emacs-zmq.dylib is linked against version 1319.*, and macos version is BigSur then it should be the same issue.

Can you also try running grep 1319 $(xcode-select -p)/SDKs/*/usr/lib/libSystem.B.tbd and see if it shows nothing? Now on my macos it does return some results, but I haven't checked before updating my OS so I am not sure if it exist before.

ed9w2in6 commented 6 months ago

@grimesdj A simple workaround is by downloading an older binary, or upgrading your OS. You can also try compiling yourself.