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

Error launching Nicotine+ #2282

Closed
ppom0 opened this issue Dec 15, 2022 · 32 comments
Closed

Error launching Nicotine+ #2282

ppom0 opened this issue Dec 15, 2022 · 32 comments
Labels

Comments

@ppom0
Copy link

ppom0 commented Dec 15, 2022

Hey, first thanks for this wonderful software!
I thought I was dreaming when I switched from SoulseekQt to Nicotine+ :D

Nicotine started to fail at launch.
I don't know why it started to act like this, because it was working on the same setup a few days ago.
I tried rm -r .local/share/nicotine/ .config/nicotine/ but it doesn't help.

Nicotine+ Version: 3.2.6
GTK Version: 3.24.34
Python Version: 3.10.8 (main, Oct 11 2022, 11:35:05) [GCC 11.3.0]
OS: NixOS 22.11
Display: sway 1.7 (wayland)

Type: <class 'BrokenPipeError'>
Value: [Errno 32] Broken pipe
Traceback:   File "/nix/store/ax1br9c00lm3xjqmfwrm9inqr8xdhyb5-nicotine-plus-3.2.6/lib/python3.10/site-packages/pynicotine/gtkgui/application.py", line 110, in on_activate
    self.core.start(ui_callback=self.frame, network_callback=self.network_callback)
  File "/nix/store/ax1br9c00lm3xjqmfwrm9inqr8xdhyb5-nicotine-plus-3.2.6/lib/python3.10/site-packages/pynicotine/pynicotine.py", line 132, in start
    self.shares = Shares(self, config, self.queue, self.network_callback, ui_callback)
  File "/nix/store/ax1br9c00lm3xjqmfwrm9inqr8xdhyb5-nicotine-plus-3.2.6/lib/python3.10/site-packages/pynicotine/shares.py", line 510, in __init__
    self.init_shares()
  File "/nix/store/ax1br9c00lm3xjqmfwrm9inqr8xdhyb5-nicotine-plus-3.2.6/lib/python3.10/site-packages/pynicotine/shares.py", line 519, in init_shares
    self.rescan_shares(init=True, rescan=rescan_startup)
  File "/nix/store/ax1br9c00lm3xjqmfwrm9inqr8xdhyb5-nicotine-plus-3.2.6/lib/python3.10/site-packages/pynicotine/shares.py", line 830, in rescan_shares
    scanner.start()
  File "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10/multiprocessing/context.py", line 288, in _Popen
    return Popen(process_obj)
  File "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10/multiprocessing/popen_fork.py", line 16, in __init__
    util._flush_std_streams()
  File "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10/multiprocessing/util.py", line 435, in _flush_std_streams
    sys.stdout.flush()
@slook
Copy link
Member

slook commented Dec 15, 2022

What is your installation method @aopom such as ppa, pip or some other repo packaging?

The path to spawned python machine (used by the shares scanner process) is different from where nicotine core is:

  • /nix/store/ax1br9c00lm3xjqmfwrm9inqr8xdhyb5-nicotine-plus-3.2.6/lib/python3.10/site-packages/
  • /nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10//multiprocessing/

scanner, scanner_queue = self.build_scanner_process(shared_folders, init, rescan, rebuild)

def build_scanner_process(self, shared_folders=None, init=False, rescan=True, rebuild=False):
import multiprocessing
# Frozen binaries only support fork (if not on Windows)
if sys.platform != "win32" and getattr(sys, 'frozen', False):
start_method = "fork"
else:
start_method = "spawn"
multiprocessing.set_start_method(start_method, force=True)

scanner = multiprocessing.Process(target=scanner.run)
scanner.daemon = True

scanner.start()

The crash is encountered at the same point as in #1843

Type: <class 'BrokenPipeError'>
Value: [Errno 32] Broken pipe

@ppom0
Copy link
Author

ppom0 commented Dec 15, 2022

It's nixpkgs/NixOS packaging (source here). I should maybe open an issue there first.

@slook
Copy link
Member

slook commented Dec 16, 2022

start_method = "fork"

Would it work if this was changed to "spawn" in the case of a BrokenPipeError exception?

https://docs.python.org/3.8/library/multiprocessing.html#multiprocessing.set_start_method
"Note that this should be called at most once, and it should be protected inside the if name == 'main' clause of the main module."

Should we run a sort "power on self test" of multiprocessing when launching nicotine and implement the frozen case check to do set_start_method() in there instead?

@mathiascode
Copy link
Member

@slook Both start methods call _flush_std_streams when initializing, so it doesn't make any difference.

@aopom How are you starting Nicotine+?

@slook
Copy link
Member

slook commented Dec 17, 2022

I thought it might depend upon if the process's stdout gets attached onto an inaccessible execution environment.

@ppom0
Copy link
Author

ppom0 commented Dec 19, 2022

@mathiascode I tried starting it in a terminal (alacritty), in a tmux session in alacritty, and with my command launcher (wofi). Both alacritty and wofi are started by the wayland server (sway). tmux is set to inherit from wayland environment variables too (SWAYSOCK and WAYLAND_DISPLAY). I also just tried running it directly from sway (swaymsg exec nicotine)

@mathiascode
Copy link
Member

I'm assuming you see log messages from Nicotine+ in the terminal?

@ppom0
Copy link
Author

ppom0 commented Dec 19, 2022

There are only GTK warnings due to my GTK theme. I just checked, changing the theme removes those warnings and Nicotine still crashes.
The logs I pasted are shown by a GUI:
image

@slook
Copy link
Member

slook commented Dec 19, 2022

Does the same thing happen if you run Nicotine+ from a local Git folder?

@ppom0
Copy link
Author

ppom0 commented Dec 20, 2022

I built it with the code from the last commit and I have the same issue :/

@mathiascode
Copy link
Member

Since there's no log output in the terminal, it would seem like stdout is broken in the main process too on your system.

To verify if only Nicotine+ is affected, could you run the following Python script?

import sys
print("test")
sys.stdout.flush()

Also, could you remove these lines and see if anything changes?

# Always use UTF-8 for print()
if sys.stdout is not None:
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding="utf-8", line_buffering=True)

@ppom0
Copy link
Author

ppom0 commented Dec 20, 2022

With this override removed, I get the exact same error :/

Traceback:   File "/nix/store/ax1br9c00lm3xjqmfwrm9inqr8xdhyb5-nicotine-plus-3.2.6/lib/python3.10/site-packages/pynicotine/gtkgui/application.py", line 110, in on_activate
    self.core.start(ui_callback=self.frame, network_callback=self.network_callback)
  File "/nix/store/ax1br9c00lm3xjqmfwrm9inqr8xdhyb5-nicotine-plus-3.2.6/lib/python3.10/site-packages/pynicotine/pynicotine.py", line 132, in start
    self.shares = Shares(self, config, self.queue, self.network_callback, ui_callback)
  File "/nix/store/ax1br9c00lm3xjqmfwrm9inqr8xdhyb5-nicotine-plus-3.2.6/lib/python3.10/site-packages/pynicotine/shares.py", line 510, in __init__
    self.init_shares()
  File "/nix/store/ax1br9c00lm3xjqmfwrm9inqr8xdhyb5-nicotine-plus-3.2.6/lib/python3.10/site-packages/pynicotine/shares.py", line 519, in init_shares
    self.rescan_shares(init=True, rescan=rescan_startup)
  File "/nix/store/ax1br9c00lm3xjqmfwrm9inqr8xdhyb5-nicotine-plus-3.2.6/lib/python3.10/site-packages/pynicotine/shares.py", line 830, in rescan_shares
    scanner.start()
  File "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10/multiprocessing/context.py", line 288, in _Popen
    return Popen(process_obj)
  File "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10/multiprocessing/popen_fork.py", line 16, in __init__
    util._flush_std_streams()
  File "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/lib/python3.10/multiprocessing/util.py", line 435, in _flush_std_streams
    sys.stdout.flush()

@mathiascode
Copy link
Member

What about the Python script in my last comment?

@ppom0
Copy link
Author

ppom0 commented Dec 21, 2022

Yeah sorry, it works fine. Prints test and no exception throwned.

@mathiascode
Copy link
Member

Is there any difference with the following commands?
nicotine --rescan
nicotine --headless

@ppom0
Copy link
Author

ppom0 commented Dec 21, 2022

nicotine --headless seems to work fine:

$ nicotine --headless
[2022-12-21 17:42:36] Loading Python 3.10.8 (main, Oct 11 2022, 11:35:05) [GCC 11.3.0]
[2022-12-21 17:42:36] Loading Nicotine+ 3.2.6
[2022-12-21 17:42:36] Loading plugin system
[2022-12-21 17:42:36] The range you specified for client connection ports was 2234-2239, but none of these were usable. Increase and/or move the range and restart Nicotine+.
[2022-12-21 17:42:36] Rescanning shares…
[2022-12-21 17:42:36] 0 folders found before rescan, rebuilding…
[2022-12-21 17:42:37] UPnP: Failed to forward external port None: UPnP is not available on this network

nicotine --rebuild as well:

$ nicotine --rebuild
[2022-12-21 17:43:48] Rescanning shares…
[2022-12-21 17:43:48] 0 folders found before rescan, rebuilding…

No GUI is spawning.

Apart from this, nicotine -s throws the same error.

@hyunlee1o
Copy link

hyunlee1o commented Dec 21, 2022

I got a similar error. It works when launched from terminal but not from desktop launcher

Nicotine+ Version: 3.3.0.dev4
GTK Version: 3.24.35
Python Version: 3.10.9 (linux)

Type: <class 'BrokenPipeError'>
Value: [Errno 32] Tubería rota
Traceback:   File "/usr/lib/python3/dist-packages/pynicotine/gtkgui/application.py", line 880, in on_activate
    core.start()
  File "/usr/lib/python3/dist-packages/pynicotine/core.py", line 200, in start
    events.emit("start")
  File "/usr/lib/python3/dist-packages/pynicotine/events.py", line 215, in emit
    function(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pynicotine/shares.py", line 569, in _start
    self.rescan_shares(init=True, rescan=rescan_startup)
  File "/usr/lib/python3/dist-packages/pynicotine/shares.py", line 876, in rescan_shares
    scanner.start()
  File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/usr/lib/python3.10/multiprocessing/context.py", line 288, in _Popen
    return Popen(process_obj)
  File "/usr/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 16, in __init__
    util._flush_std_streams()
  File "/usr/lib/python3.10/multiprocessing/util.py", line 435, in _flush_std_streams
    sys.stdout.flush()

@slook
Copy link
Member

slook commented Dec 22, 2022

What is your OS distro, and which method of installation @hyunlee1o ?

@hyunlee1o
Copy link

hyunlee1o commented Dec 22, 2022 via email

@mathiascode
Copy link
Member

Related issues:
#1965
#1978

@mathiascode
Copy link
Member

@hyunlee1o Which desktop environment are you using? I can't reproduce the issue with a default Debian Testing installation (GNOME).

@hyunlee1o
Copy link

hyunlee1o commented Dec 27, 2022 via email

@mathiascode
Copy link
Member

I managed to reproduce the issue. Run this command in a terminal:
nicotine |:

@hyunlee1o
Copy link

hyunlee1o commented Dec 31, 2022

Yeah, it crashes in terminal :3

Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pynicotine/gtkgui/application.py", line 884, in on_activate
    core.start()
  File "/usr/lib/python3/dist-packages/pynicotine/core.py", line 200, in start
    events.emit("start")
  File "/usr/lib/python3/dist-packages/pynicotine/events.py", line 215, in emit
    function(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pynicotine/shares.py", line 569, in _start
    self.rescan_shares(init=True, rescan=rescan_startup)
  File "/usr/lib/python3/dist-packages/pynicotine/shares.py", line 876, in rescan_shares
    scanner.start()
  File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/usr/lib/python3.10/multiprocessing/context.py", line 288, in _Popen
    return Popen(process_obj)
  File "/usr/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 16, in __init__
    util._flush_std_streams()
  File "/usr/lib/python3.10/multiprocessing/util.py", line 435, in _flush_std_streams
    sys.stdout.flush()
BrokenPipeError: [Errno 32] Tubería rota

Original exception was:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pynicotine/gtkgui/application.py", line 884, in on_activate
    core.start()
  File "/usr/lib/python3/dist-packages/pynicotine/core.py", line 200, in start
    events.emit("start")
  File "/usr/lib/python3/dist-packages/pynicotine/events.py", line 215, in emit
    function(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pynicotine/shares.py", line 569, in _start
    self.rescan_shares(init=True, rescan=rescan_startup)
  File "/usr/lib/python3/dist-packages/pynicotine/shares.py", line 876, in rescan_shares
    scanner.start()
  File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/usr/lib/python3.10/multiprocessing/context.py", line 288, in _Popen
    return Popen(process_obj)
  File "/usr/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 16, in __init__
    util._flush_std_streams()
  File "/usr/lib/python3.10/multiprocessing/util.py", line 435, in _flush_std_streams
    sys.stdout.flush()
BrokenPipeError: [Errno 32] Tubería rota
Exception ignored in: <_io.TextIOWrapper name='<stdout>' encoding='utf-8'>
BrokenPipeError: [Errno 32] Tubería rota
Fatal Python error: _enter_buffered_busy: could not acquire lock for <_io.BufferedReader name='<stdin>'> at interpreter shutdown, possibly due to daemon threads
Python runtime state: finalizing (tstate=0x0000557d5e372870)

Current thread 0x00007f21d427f040 (most recent call first):
  <no Python frame>
fish: Process 305934, 'nicotine' from job 1, 'nicotine |:' terminated by signal SIGABRT (Abort)

@mathiascode
Copy link
Member

Could you test the 3.2.x branch and see if the issue is resolved for you?
https://github.com/nicotine-plus/nicotine-plus/blob/3.2.x/doc/TESTING.md

@hyunlee1o
Copy link

I tested and it run without issue

@ppom0
Copy link
Author

ppom0 commented Jan 2, 2023

Fixes the bug for me too! Thanks a lot :D

@ppom0
Copy link
Author

ppom0 commented Jan 2, 2023

Hum, It worked one time, then I ran the older version by mistake and now I have the issue again with the last 3.2.x version, even after rm -r .local/share/nicotine/ .config/nicotine/

@mathiascode
Copy link
Member

mathiascode commented Jan 2, 2023

Hum, It worked one time, then I ran the older version by mistake and now I have the issue again with the last 3.2.x version, even after rm -r .local/share/nicotine/ .config/nicotine/

That doesn't make much sense. Can you re-download the latest 3.2.x development build, to ensure that it's actually the latest. If nothing changes. can you paste the error?

@slook
Copy link
Member

slook commented Jan 7, 2023

@aopom @hyunlee1o The latest stable release includes the fix, please check everything is okay with it on your systems. Thank you.

Nicotine+ 3.2.8 released on January 6th 2023 https://nicotine-plus.org/doc/DOWNLOADS

@hyunlee1o
Copy link

Working, thanks for your time and effort.

@ppom0
Copy link
Author

ppom0 commented Jan 10, 2023

Yes it works!
Thank a lot

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

No branches or pull requests

4 participants