-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Linux Prebuilt Binary Failure Behavior for require
with Bad Path
#14132
Comments
Hi. Could you please elaborate the And post the output from PhantomJS with Thanks. |
I test two "bad paths":
Both cause the machine to become non-responsive (big red button only). Since the machine must be physically rebooted at that point, each trial to narrow this down also does (no input possible). I'll not (or likely not) be able to get any output from phantomJS (or be able to persist/retrieve any output). |
Here is something else to try. Make sure the
This should be able to recover control after the bug manifests, unless we're actually looking at a kernel bug here; but it also attempts to make sure that the output hits the disk, so if you do have to hit the big red button, If this works, |
Also, please give concrete examples of what you mean by "totally undefined" and "non-existent file (well-formed)" pathname. (As far as the operating system is concerned, there is no such thing as an ill-formed pathname. Any byte sequence that's a valid C-string, and fits under some large and arbitrary length limit, is acceptable as input to the |
I'm still preparing your script for test/recovery (thank you!).
|
I just realized that there was a bug in my script. Do this instead:
The only change is on the last line, which needs to be FYI, this is what happens when I try to reproduce the problem in my environment:
That's using a local build of development trunk, not the prebuilt binary, but it oughtn't matter. |
oops, pushed the wrong button |
@ariya Did you mean to close this one? |
@zackw No, I was confused as well. |
OK, ran it. Two sections here, command output and trace.log output. Command outputI waited for a minute and ^C'd the process since it didn't kill properly.
Trace Log OutputHere's the last ~100 lines or so of the trace.log
|
FWIW, here is what changing to undefined input looked like: Command output
Trace log outputI did not wait as long to ^C.
|
New information. I achieved the same non-responsive system after running code that tested for bad input (skipping the previously suspected require), and instead just threw a plain error when the bad input was detected: throw new Error('invalid module supplied'); Just throwing this error caused the same non-responsive system. So moving focus to my error handler: function _exit(code, msg) {
if (code !== 0) {
console.error(msg);
} else {
console.log(msg);
}
phantom.exit(code);
}
/**
* Global error handler
*/
phantom.onError = function(msg, trace) {
var msgStack = ["PhantomJS error: " + msg];
if (trace && trace.length) {
msgStack.push("Trace:");
trace.forEach(function(t) {
msgStack.push(" -> " + (t.file || t.sourceURL) + ": " + t.line + (t.function ? " (in function " + t.function +")" : ""));
});
}
_exit(-1, msgStack.join("\n"));
}; This is the probable cause, although I still don't understand why this is wrong as of phantomjs 2.x. Any advice/direction appreciated. |
After many more trials/reboots, I found that simply not calling the /**
* Global error handler
*/
phantom.onError = function(msg, trace) {
var msgStack = ["PhantomJS error: " + msg];
if (trace && trace.length) {
msgStack.push("Trace:");
trace.forEach(function(t) {
msgStack.push(" -> " + (t.file || t.sourceURL) + ": " + t.line + (t.function ? " (in function " + t.function +")" : ""));
});
}
console.log(msgStack.join("\n"));
phantom.exit(-1);
}; (I switched to console.log for output preference only). Again, this was a problem for the linux prebuilt binary only. Hopefully, this information is helpful to the project. Thanks again for all the assistance here. |
I'm trying to upgrade to Phantomjs 2.x and found a behavior I'm not understanding.
Using the Linux prebuilt binary, on Ubuntu 14.04.4, calling
require
from a Phantomjs script with a bad path causes the entire system to get so busy that it becomes unresponsive.Tried both Macosx binary and Linux binary - The prebuilt Macosx binary fails nicely.
Any help understanding the root cause is greatly appreciated.
The text was updated successfully, but these errors were encountered: