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

Opening "Preferences" results in segfault on macOS (crash, QtMultimedia camera handling) #7725

Closed
bitkarrot opened this issue Mar 20, 2022 · 15 comments

Comments

@bitkarrot
Copy link
Contributor

See attached file for crash report. Happens when clicking on 'preferences' or while closing open wallets.
electrum_crash.txt

@SomberNight
Copy link
Member

Happens when clicking on 'preferences'

Maybe that's related to QtMultimedia and the camera-handling...

Could you test going into the Console tab (menubar>View>Show Console), and then running:

from PyQt5.QtMultimedia import QCameraInfo

Also, to try to narrow things down, could you test if Electrum 4.1.5 also reproduces the crash?

crash happens [...] while closing open wallets

if you mean during application shutdown (e.g. closing last open wallet), that might be #6889

@bitkarrot
Copy link
Contributor Author

Could you test going into the Console tab (menubar>View>Show Console), and then running:

from PyQt5.QtMultimedia import QCameraInfo

Screen Shot 2022-03-20 at 4 57 44 PM

this import actually returns nothing.

tried to repeat the 'preferences' crash from last night. i noticed that just open/closing wallets today its okay. when new wallets are closed and opened, that's when the crash happens, sometimes on preferences, sometimes when closing wallets.

i'm on bigsur 11.6 if that helps.

when i get a chance to uninstall i'll try out the earlier version

if you mean during application shutdown (e.g. closing last open wallet), that might be #6889

yes, its definitely #6889

@bitkarrot
Copy link
Contributor Author

bitkarrot commented Mar 21, 2022

i installed the .dmg, not sure if that had an impact.

perhaps i should run from source? (need to set up dev environment anyway ;)

will try to install from source, and then see if i can get anything from the cli

@danshao
Copy link

danshao commented Mar 21, 2022

Also crashes on non M1.

I'm on Mac OS Monterey 12.3 Macbook Air 2019. Crash occurs whenever I hit the Preferences menu button.

@SomberNight
Copy link
Member

SomberNight commented Mar 21, 2022

Could either of you specifically test the following steps:

  • start Electrum, open a wallet
  • go into the Console tab (menubar>View>Show Console), and then run:
    from PyQt5.QtMultimedia import QCameraInfo
    
  • open Preferences, see if it crashes

That is, assuming the crash is related to QtMultimedia, I would like to test whether it helps to run the import before the Preferences dialog is opened.

@danshao
Copy link

danshao commented Mar 21, 2022

Does not crash after I type that into console.

@bitkarrot
Copy link
Contributor Author

Mine does not crash anymore when the above is run.

Could either of you specifically test the following steps:

* start Electrum, open a wallet

* go into the `Console` tab (menubar>`View`>`Show Console`), and then run:
  ```
  from PyQt5.QtMultimedia import QCameraInfo
  ```

* open Preferences, see if it crashes

That is, assuming the crash is related to QtMultimedia, I would like to test whether it helps to run the import before the Preferences dialog is opened.

@SomberNight SomberNight added this to the 4.2.1 milestone Mar 21, 2022
@SomberNight SomberNight changed the title 4.2 electrum on Apple M1 crashes on GUI Opening "Preferences" results in segfault on macOS (crash) Mar 21, 2022
@SomberNight SomberNight changed the title Opening "Preferences" results in segfault on macOS (crash) Opening "Preferences" results in segfault on macOS (crash, QtMultimedia camera handling) Mar 21, 2022
@SomberNight
Copy link
Member

Thanks. So this seems identical to the issue described in Electron-Cash#1545.
I could not so far reproduce this (tried on macos 10.15.3 and 11.3).

Regardless, looking at that PR, it seems #7727 might be enough to fix this.
Would either of you be able to test running from source, try to reproduce, and see if #7727 works?

@bitkarrot
Copy link
Contributor Author

i checked out SomberNight:202203_qtcamera_preferences_crash

on M1 Apple, Big Sur, version 11.6

built fine, however pycryptodomex', 'cryptography missing from the build process and also #6948

$  ./run_electrum
Error: Failed to load libsecp256k1.
E | ecc_fast | libsecp256k1 library failed to load. exceptions: [OSError('dlopen(/Users/bitcarrot/electrum/electrum/libsecp256k1.0.dylib, 6): image not found'), OSError('dlopen(libsecp256k1.0.dylib, 6): image not found')]

I can try to build this on an intel mac later tonight see if we can get an electrum working.

@bitkarrot
Copy link
Contributor Author

bitkarrot commented Mar 22, 2022

I was able to get libsecp256 issue resolved, by installing bitcoin-core version,( https://github.com/bitcoin-core/secp256k1#build-steps, make sure built with --enable-module-recovery) however Building on Apple M1 Big Sur has issue with PyQt5, as posted in Dec 2021, see issue also described here:
bordaigorl/rmview#119

I will try rosetta to get PyQt5 installed tomorrow when i have time and see if that can get electrum running on this OS

@bitkarrot
Copy link
Contributor Author

Problem solved for running from source:
An alternative to getting PyQt5 installed on Apple M1 Big Sur:
https://www.zhihu.com/question/437075754/answer/1993415429

Do the following since pip install pyqt5 won't work:

brew install pyqt5
echo 'export PATH="/opt/homebrew/opt/qt@5/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/pyqt@5/5.15.4_1/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Running it and clicking 'Preferences' is ok. Does not crash.
Here are the logs from ./run_electrum on https://github.com/SomberNight/electrum/tree/202203_qtcamera_preferences_crash,

there are some exceptions thrown:

E | asyncio | Task exception was never retrieved
future: <Task finished name='Task-136' coro=<Interface.get_estimatefee() done, defined at /Users/bitcarrot/github/electrum/electrum/interface.py:1093> exception=RequestTimedOut("request timed out: ('blockchain.estimatefee', [2]) (id: 6)")>
Traceback (most recent call last):
  File "/Users/bitcarrot/github/electrum/electrum/interface.py", line 171, in send_request
    response = await asyncio.wait_for(
  File "/opt/homebrew/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py", line 442, in wait_for
    return await fut
  File "/Users/bitcarrot/Library/Python/3.9/lib/python/site-packages/aiorpcx/session.py", line 540, in send_request
    return await self._send_concurrent(message, future, 1)
  File "/Users/bitcarrot/Library/Python/3.9/lib/python/site-packages/aiorpcx/session.py", line 512, in _send_concurrent
    return await future
  File "/Users/bitcarrot/Library/Python/3.9/lib/python/site-packages/aiorpcx/curio.py", line 382, in __aexit__
    raise TaskTimeout(self._secs) from None
aiorpcx.curio.TaskTimeout: task timed out after 30s

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/bitcarrot/github/electrum/electrum/interface.py", line 1100, in get_estimatefee
    res = await self.session.send_request('blockchain.estimatefee', [num_blocks])
  File "/Users/bitcarrot/github/electrum/electrum/interface.py", line 175, in send_request
    raise RequestTimedOut(f'request timed out: {args} (id: {msg_id})') from e
electrum.interface.RequestTimedOut: Network request timed out.
E | asyncio | Task exception was never retrieved
future: <Task finished name='Task-135' coro=<Interface.get_estimatefee() done, defined at /Users/bitcarrot/github/electrum/electrum/interface.py:1093> exception=RequestTimedOut("request timed out: ('blockchain.estimatefee', [5]) (id: 5)")>
Traceback (most recent call last):
  File "/Users/bitcarrot/github/electrum/electrum/interface.py", line 171, in send_request
    response = await asyncio.wait_for(
  File "/opt/homebrew/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py", line 442, in wait_for
    return await fut
  File "/Users/bitcarrot/Library/Python/3.9/lib/python/site-packages/aiorpcx/session.py", line 540, in send_request
    return await self._send_concurrent(message, future, 1)
  File "/Users/bitcarrot/Library/Python/3.9/lib/python/site-packages/aiorpcx/session.py", line 512, in _send_concurrent
    return await future
  File "/Users/bitcarrot/Library/Python/3.9/lib/python/site-packages/aiorpcx/curio.py", line 382, in __aexit__
    raise TaskTimeout(self._secs) from None
aiorpcx.curio.TaskTimeout: task timed out after 30s

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/bitcarrot/github/electrum/electrum/interface.py", line 1100, in get_estimatefee
    res = await self.session.send_request('blockchain.estimatefee', [num_blocks])
  File "/Users/bitcarrot/github/electrum/electrum/interface.py", line 175, in send_request
    raise RequestTimedOut(f'request timed out: {args} (id: {msg_id})') from e
electrum.interface.RequestTimedOut: Network request timed out.

@SomberNight
Copy link
Member

Running it and clicking 'Preferences' is ok. Does not crash.
Here are the logs from ./run_electrum on https://github.com/SomberNight/electrum/tree/202203_qtcamera_preferences_crash,

Thanks for testing.

there are some exceptions thrown:

 E | asyncio | Task exception was never retrieved
 [...]
 aiorpcx.curio.TaskTimeout: task timed out after 30s

That's unrelated and should be harmless.

@SomberNight
Copy link
Member

Ok, so #7727 hopefully fixes this. Closing.

@bitkarrot
Copy link
Contributor Author

Regarding the build from source notes on Apple M1, is there a place on electrum-docs or elsewhere I can consolidate my notes? It was a bit cumbersome the build process?

Thanks @SomberNight

@SomberNight
Copy link
Member

@bitkarrot you can create a file, e.g. notes_for_arm.md inside contrib/osx, and make a PR.

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

No branches or pull requests

4 participants
@danshao @SomberNight @bitkarrot and others