nodejs / node-v0.x-archive

Moved to https://github.com/nodejs/node
34.44k stars 7.3k forks source link

setting process.title hangs the process #8279

Closed bajtos closed 10 years ago

bajtos commented 10 years ago

Recently I started to experience a problem with npm, where after certain number of invocations the script not longer works, it hangs forever.

I managed to track down the problem to this line in bin/npm-cli.js:

process.title = "npm"

When I add console logs before and after the line, the first log is printed but the second is not.

Once this problem occurs for the first time, every run of npm hangs until the machine is rebooted. In fact, any Node.js script calling process.title=value hangs too.

I did not manage to figure out what condition or actions triggers the problem.

Node version: v0.10.31, v0.10.24 npm version: 1.4.23, 1.3.21 Platform: OSX 10.9.4

bajtos commented 10 years ago

FWIW, it looks like an OSX-specific problem as the system cannot even shut down at that point.

indutny commented 10 years ago

Don't tell me that Apple ruined our proctitle again :(

jbergstroem commented 10 years ago

How many times are we talking about? I'm running v0.10.31 (installed through homebrew) on 10.9.4 and tried something similar to:

for i in {1..1000}; do
     node -e "console.log('${i} before');process.title='changed';console.log('${i} after');"
done

..without being able to reproduce.

bajtos commented 10 years ago

To be honest, the trigger may be totally unrelated to Node.js, since it seems that the whole OS X is in a weird state at that point.

I don't restart my machine every day, just put it to sleep. After few days of work, where I run various node processes including npm, but also other stuff like WebStorm, Chrome, Colloquy, SlackChat, etc., I run npm install and it suddenly hangs.

I am not sure how to proceed with this issue. I don't mind closing it until I (or somebody else) is able to provide more info.

indutny commented 10 years ago

Yeah, I wasn't able to reproduce it either... Haven't seen it myself.

jbergstroem commented 10 years ago

(just adding my own experience for reference)

I rarely restart my desktop (say once a month) and use it as my main nodejs development rig. I've yet to run into something similar.

bajtos commented 10 years ago

Here is the trigger I was able to find: the project I am working on calls gulp-install to install npm dependencies in a subdirectory. The install process spawns a lot of child processes, probably too fast, thus Error: spawn EAGAIN is reported.

child_process.js:927
    throw errnoException(process._errno, 'spawn');
          ^
Error: spawn EAGAIN
    at errnoException (child_process.js:980:11)
    at ChildProcess.spawn (child_process.js:927:11)
    at Object.exports.spawn (child_process.js:715:9)
    at /Users/bajtos/src/strong/studio/node_modules/gulp-install/lib/commandRunner.js:11:28
    at /Users/bajtos/src/strong/studio/node_modules/gulp-install/node_modules/which/which.js:55:18
    at Object.oncomplete (fs.js:107:15)

After that, process.title="..." hangs.

jbergstroem commented 10 years ago

@bajtos We're going off topic here, but I'm guessing your hitting your ulimit. Your ps aux should be pretty long. If you have further issues I'm suggesting you ask at the nodejs mailing list.

bajtos commented 10 years ago

I managed to write an example that is reliably reproducing the problem. Let's move the discussion to a new bug.

indutny commented 10 years ago

hey @bajtos the Apple guys has requested the following info, could you please help me with it? ;)

Engineering has requested the following information in order to further investigate the issue:

Do you have any crashlogs for launchservicesd, or could you attach a sysdiagnose of a machine in this situation?

Please provide your response or results by updating your bug report.

Please compress any bundled files (e.g. nested folders) prior to uploading.
bajtos commented 10 years ago

Do you have any crashlogs for launchservicesd,

I don't know, where shall I look for them?

or could you attach a sysdiagnose of a machine in this situation?

So the idea is to run the fork bomb until process.title hangs the node process; and then run sysdiagnose?

indutny commented 10 years ago

I have no idea, let's just submit sysdiagnose output right when the process.title hangs.

bajtos commented 9 years ago

@indutny I've sent you a link to Google Drive document with the sysdiagnose output. Let me know if you can download it.

indutny commented 9 years ago

Thank you @bajtos ! Could you please add fedor.indutny@gmail.com to a share list?

bajtos commented 9 years ago

Could you please add fedor.indutny@gmail.com to a share list?

Done.

indutny commented 9 years ago

Thank you!

bajtos commented 9 years ago

No problem, I am glad to help.

indutny commented 9 years ago

@bajtos

Engineering has requested the following information in order to further investigate the issue:

Was this sysdiagnose taken when a machine was in the state that all applications were hung inside LSApplicationCheckIn?

Please provide your response or results by updating your bug report.

Please compress any bundled files (e.g. nested folders) prior to uploading.

I assume - "yes", but asking here just in case.

bajtos commented 9 years ago

Actually no, I killed the hanging app. I'll create a new sysdiagnose then, probably early next week.

bajtos commented 9 years ago

Here is what I did:

The result is on Google Drive again, shared with fedor.indutny@gmail.com.

Now I can do a hard restart of my machine again.

indutny commented 9 years ago

Thank you, @bajtos !