flyingrhinonz / nccm

GNU General Public License v3.0
133 stars 23 forks source link

nccm crashes on any keypress #11

Closed wdatkinson closed 2 years ago

wdatkinson commented 2 years ago

Long time NCCM user on multiple machines. Brand new Manjaro Cinnamon install, less than 24 hours ago. I have Python 3.9.7 installed along with python-yaml and yamllint.

The nccm.yml passes yamllint, with no issues reported.

When I launch nccm it runs, but as soon as I press any key, I get:

Traceback (most recent call last): File "/usr/local/bin/nccm", line 2482, in <module> main() File "/usr/local/bin/nccm", line 2425, in main CommandLine = curses.wrapper(MainCursesFunction) File "/usr/lib/python3.9/curses/__init__.py", line 94, in wrapper return func(stdscr, *args, **kwds) File "/usr/local/bin/nccm", line 2064, in MainCursesFunction or UserKey in ConnectionsList.KeyboardBindings['nccm_key_ctrl_u'] ) KeyError: 'nccm_key_ctrl_u'

Running nccm with the -d generates the following syslog entries at crash time:

Nov 26 17:56:45 linux-macbook-air nccm[10200]: <DEBUG> (2021-11-26 17:56:45.847 , PN: MainProcess , MN: nccm , FN: MainCursesFunction , LI: 2038 , TN: MainThread): Keyboard entry: UserKey == 114 Nov 26 17:56:45 linux-macbook-air nccm[10200]: <DEBUG> (2021-11-26 17:56:45.847 , PN: MainProcess , MN: nccm , FN: MainCursesFunction , LI: 2070 , TN: MainThread): Handle text entry in FilterBox ...

All of my other manjaro machines are xfce, this is my first cinnamon install. Also, could there be an issue with the fact I'm running on a Macbook Air? No dual OS's, just manjaro.

Any suggestions would be appreciated.

flyingrhinonz commented 2 years ago

The last line logged before the crash was the last line nccm was still happy with. What key were you pressing?

Can you try pressing TAB to move to the CONN textbox and let me know if it crashes there too.

Try pressing other keys, numbers, space, tab. See if you can get nccm to accept a particular key. Let me know what results you get.

You mentioned macbook air - try doing the same test on a box that works for you and look at the key code you get in both cases - perhaps it's different - in which case you'll need to reprogram the key bindings in the nccm.yml file (or there really is a bug...).

One more test - I suspect the crash is occurring in the ProcessKey method ( def ProcessKey(self, Key, KeyboardBindings): ) . Can you add LogWrite.debug in there at various places and see which is the last one that logs before it crashes?

wdatkinson commented 2 years ago

Keypress doesn't seem to matter. And I always see the 'nccm_key_ctrl_u' which I'm not sure should be the same regardless of keypress?

Tab does work and moves the cursor between Conn and Filter.

Entering a connection number triggers the crash, as well as cursor keys or any other key.

I am experiencing no further keyboard anomalies across other laptop operations.... So far anyway.

You'll have to forgive me, while I've sent time with software developers, I'm not a programmer. At best, I'm a hack, but can get around.

That being said, I'm happy to test. Where do I add the LogWrite.debug? You mentioned various places, which threw me off.

wdatkinson commented 2 years ago

Running nccm -d and immediately pressing the down arrow give me this in syslog:

Nov 27 09:15:56 linux-macbook-air nccm[102180]: <DEBUG> (2021-11-27 09:15:56.619 , PN: MainProcess , MN: nccm , FN: MainCursesFunction , LI: 2038 , TN: MainThread): Keyboard entry: UserKey == 258

Trying to replicate the testing using other keys gives me a ton of log entries unlike the above, which just spits out one or two lines, one of which is the UserKey message.

Here is a the result of pressing 9:

Nov 27 09:22:09 linux-macbook-air nccm[102225]: <DEBUG> (2021-11-27 09:22:09.840 , PN: MainProcess , MN: nccm , FN: MainCursesFunction , LI: 2038 , TN: MainThread): Keyboard entry: UserKey == 57 Nov 27 09:22:09 linux-macbook-air nccm[102225]: <DEBUG> (2021-11-27 09:22:09.841 , PN: MainProcess , MN: nccm , FN: MainCursesFunction , LI: 2070 , TN: MainThread): Handle text entry in FilterBox ...

flyingrhinonz commented 2 years ago

Thanks for testing this.

Later today I'll create a new nccm that does more logging and attach it here as a zipped file. Please replace your existing nccm program with the one I will give you. Also please backup your nccm.yml file and leave only one connection (for privacy reasons just create a connection name and configure it 192.168.1.1 - anything you want - as long as nccm loads it correctly). Keep all the nccm related configs because they are needed.

I need to figure out exactly where the crash is happening so we might need to do this a couple times until we narrow down the spot. Can be tricky because it works for me and I can't debug a working program :(

After you test I'll need the entire nccm log data which you are welcome to put into a zip file and email to me along with the stripped down nccm.yml file you are using. You're putting a single fake host in there so there won't be any private info. Just make sure you ENABLE the insecure logging (disable the privacy logging setting in nccm.yml so that everything is logged).

As usual - run this with the: --debug flag for maximum logging.

flyingrhinonz commented 2 years ago

Here's how to get recent logs. Change the -10min to the recent time you want to collect:

journalctl -t "nccm" --since -10min > /tmp/file.txt

Meanwhile I've updated nccm with detailed keypress logging.

nccm_keypress_debugging.zip

put your nccm.yml and log file into a zip and email to me per email on the project page. or if you have no private data in your files then put the zip file here into the issue.

wdatkinson commented 2 years ago

Ok, while setting up things up to test, I pulled the default nccm.yml from my git clone. When I launch nccm, I was able to move the cursor around and select/launch a session.

yamllint has no issues with my .yml file or the default one (as one would expect).

If I scp my .yml from my working laptop (Manjaro XFCE), all connections load, but I'm back to the crashes when I try to do anything.

So obviously this seems to be an issue with the .yml file, but one not caught by yamllint or other tools (https://yamlchecker.com/).

Given this new info, any changes to how we proceed? Will the debug version I have still yield anything useful if I run it against one or both .yml files?

Happy to help out.

flyingrhinonz commented 2 years ago

yamllint checks for syntax errors, but is not aware of program-specific stuff.

We stay on plan because I'd like to know where the crashes are coming from and make nccm more resilient or at least log the final step before it fails which will give the user an idea what to check for.

Use your crashing nccm.yml . Strip out your connections and put in a fake one. Use the nccm program i supplied. Run nccm and type in the minimum amount of keypresses required to cause a crash. Get the logs per the journalctl command I gave. Email me the logs + nccm.yml + error message on screen.

I'll work out the fix.

Thanks.

wdatkinson commented 2 years ago

Ok, I have everything ready, but I cannot find your email. I looked under every heading labeled project and even did a ctrl-f for 'email' on multiple screens with no luck. Even looked under your main profile. So obviously their anti-spam plan is working, perhaps a bit too well.

I would prefer to send directly due to privacy concerns. Can you please point me to the email address to use?

flyingrhinonz commented 2 years ago

Hi,

flyingrhino AT orcon DOT net DOT nz

It's all over the place - second line in github, inside the nccm help page, etc :)

I'll look at it on the weekend, got a busy time at work this week.

Ken.

flyingrhinonz commented 2 years ago

Found it - your nccm.yml is missing this config:

nccm_key_ctrl_u: # Ctrl-u (clears textbox text)

which is a new addition from one of the latest nccm releases. crashed for me too in the same way using your nccm.yml .

download the newest nccm.yml from the project page and update it with the settings from your old nccm.yml .

wdatkinson commented 2 years ago

Confirmed. Thanks for the research and support!