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

Segmentation Fault when retrieving window title #377

Closed
1 of 3 tasks
dwighthouse opened this issue Feb 25, 2022 · 13 comments
Closed
1 of 3 tasks

Segmentation Fault when retrieving window title #377

dwighthouse opened this issue Feb 25, 2022 · 13 comments
Labels
bug Something isn't working DONE Implementation is done, but not yet merged into master

Comments

@dwighthouse
Copy link

dwighthouse commented Feb 25, 2022

Version
Node v17.0.1
nut.js v2.0.1

Short overview
Trying to retrieve title of any window results in Seg Fault and no other information, program ends immediately.

Issue occurs on

  • Virtual machine
  • Docker container
  • Dev/Host system

Detailed error description
Seg fault is occurring on Big Sur any time I attempt to find a window title, either through getWindows or getActiveWindow.

Steps to reproduce error
Run this script:

import { getActiveWindow } from '@nut-tree/nut-js';

(async () => {
    const window = await getActiveWindow();
    const title = await window.title;
    console.log(title);
})();

Expected Result:
Terminal

Actual Result:
zsh: segmentation fault node index.js

@s1hofmann s1hofmann added the bug Something isn't working label Mar 3, 2022
@s1hofmann
Copy link
Member

s1hofmann commented Mar 3, 2022

Observation: Reproducibly segfaults when executed in Terminal.app, no matter which window is currently active. Runs fine in e.g. iTerm, though

Edit: This was due to my setup. Reproducibly segfaults in any terminal

@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Apr 26, 2022
@s1hofmann
Copy link
Member

Still open

@github-actions github-actions bot removed the stale label Apr 29, 2022
@mwarger
Copy link

mwarger commented May 4, 2022

I also see this error regardless of the terminal used. Tried in iTerm and got the same error.

@github-actions
Copy link

github-actions bot commented Jun 4, 2022

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Jun 4, 2022
@s1hofmann s1hofmann removed the stale label Jun 8, 2022
@jzombie
Copy link

jzombie commented Jun 12, 2022

Can confirm this issue is happening on Mac M1 using Terminal and iTerm for accessing window titles.

@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Jul 13, 2022
@github-actions
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

@s1hofmann s1hofmann removed the stale label Aug 7, 2022
@s1hofmann s1hofmann reopened this Aug 7, 2022
@sublimator
Copy link

image

Crashing for me too

@s1hofmann
Copy link
Member

s1hofmann commented Sep 19, 2022

Status update:

This issue had me banging my head for several months now.
I might have finally tracked down the root cause 💪

Still WIP

@sublimator
Copy link

Great to hear.
Liking the lib so far.

@s1hofmann s1hofmann added the WIP Work in progress label Sep 20, 2022
@s1hofmann s1hofmann added DONE Implementation is done, but not yet merged into master and removed WIP Work in progress labels Sep 20, 2022
@s1hofmann s1hofmann changed the title Big Sur Segmentation Fault when retrieving window title Segmentation Fault when retrieving window title Sep 22, 2022
@s1hofmann
Copy link
Member

Root cause: Reading the kCGWindowName property requires an application to be given Screen Recording permissions. If this is not the case, it'll just return nil which caused the segfault.

Fixed in release 2.3.0 that just went live.

@sublimator
Copy link

Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working DONE Implementation is done, but not yet merged into master
Projects
None yet
Development

No branches or pull requests

5 participants