Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

PhantomJS Crashes consistently with bus error 10 #14388

Closed
JalfResi opened this issue Jul 4, 2016 · 8 comments
Closed

PhantomJS Crashes consistently with bus error 10 #14388

JalfResi opened this issue Jul 4, 2016 · 8 comments
Assignees

Comments

@JalfResi
Copy link

JalfResi commented Jul 4, 2016

  1. Which version of PhantomJS are you using? Tip: run phantomjs --version.
    2.1.1
  2. What steps will reproduce the problem?
    1. run netsniff.js script with the following url: https://www.hertz.com/ e.g:
      $ phantomjs --debug=true netsniff.js https://www.hertz.com/
      Crashes for any url on the above domain
  3. Which operating system are you using?
    OSX El Capitan v10.11.5
  4. Did you use binary PhantomJS or did you compile it from source?
    Binary I think (maybe homebrew)
  5. Please provide any additional information below.

Couldn't produce a stack trace but have attached the crash dump.

hertz-crash-output.txt

phantomjs_2016-07-04-151957_C07JVKD6DWYL-2.crash.zip

@JalfResi JalfResi changed the title PhantomJS Crashes PhantomJS Crashes consistently with bus error 10 Jul 4, 2016
@JalfResi
Copy link
Author

JalfResi commented Jul 4, 2016

Tried on a different OSX and noticed that the line:
$ phantomjs --debug=true netsniff.js https://www.hertz.com/

works once, and then any subsequent runs produce the crash from then on.

This was also duplicated on Ubuntu:
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty

Same result: first run works fine, subsequent runs produce a segmentation fault with a core dump.

@JalfResi
Copy link
Author

JalfResi commented Jul 4, 2016

Issue remains post reboot!

@JalfResi JalfResi closed this as completed Jul 4, 2016
@JalfResi JalfResi reopened this Jul 4, 2016
@JalfResi
Copy link
Author

JalfResi commented Jul 4, 2016

Closed by mistake!

@allquixotic
Copy link

Unless you can dig into this with a debug build and run through the stack trace and figure out exactly what is causing the crash, it's unlikely that this will get fixed.

Tsk, tsk... running PhantomJS in production; you should know better! ;)

This is a small, community-maintained project with basically no active maintainers (those who do contribute, do so on their own agenda, and rarely look at issues unless it affects them in their workload). You won't find much support here I'm afraid.

Anyway..... if you were using the Selenium interface to PhantomJS, you could have easily swapped out PhantomJS for something better, like jBrowserDriver (uses the Java VM's built-in webkit engine), or temporarily swap in a "headed" browser like Firefox just to get your work done.

For your own sanity I would recommend you investigate porting your work over to Selenium ASAP. Even if you end up using Selenium with PhantomJS via GhostDriver, in the long run you'll benefit by being able to swap out PhantomJS for something else with minimal code changes.

@JalfResi
Copy link
Author

JalfResi commented Jul 4, 2016

Agree on all points - the original plan was to integrate our tools directly using WebDriver to talk to any target browser we like, but as ever, time can always be better spent elsewhere. Anyway, I actually have pinned this issue down exactly, and have fix for this in place, so once I've finished testing I'll update the issue.

It appears that the issue has something to do with the ApplicationCache.db file - there are entries in there that do not match files on the FS, so I think its crashing there - clearing the tables (or even better, I'm hoping to use --disk-cache-path to specify a file I can delete after each request) appears to magically spring phantomjs back to life.

I should note that we do NOT want any caching of any kind occurring as we use our own huge systems cache, so I appreciate this fix may not be appropriate for everyone

@vitallium vitallium self-assigned this Jul 6, 2016
@JalfResi
Copy link
Author

I've found a non-breaking fix for those who are happy to disable the PhantomJS cache to get this working. Simple run the following sqlite queries on the ApplicationCache.db. The location of this file differs depending on your OS:

OSX:
~/Library/Application\ Support/Ofi\ Labs/PhantomJS/ApplicationCache.db

Ubuntu:
~/.local/share/Ofi\ Labs/PhantomJS/ApplicationCache.db
~/.qws/share/data/Ofi\ Labs/PhantomJS/ApplicationCache.db
OR
/root/.local/share/Ofi\ Labs/PhantomJS/ApplicationCache.db
/root/.qws/share/data/Ofi\ Labs/PhantomJS/ApplicationCache.db

The following SQL deletes all entries from the cache, and adds triggers which prevent new entries being added to the cache. This effectively stops the crashing.

DELETE FROM Caches;
DELETE FROM CacheAllowsAllNetworkRequests;
DELETE FROM CacheEntries;
DELETE FROM CacheGroups;
DELETE FROM CacheResourceData;
DELETE FROM CacheResources;
DELETE FROM Origins;

CREATE TRIGGER IF NOT EXISTS DisableCacheInsert AFTER INSERT ON Caches BEGIN DELETE FROM Caches WHERE id = NEW.id; END;
CREATE TRIGGER IF NOT EXISTS DisableCacheAllowsAllNetworkRequestsInsert AFTER INSERT ON CacheAllowsAllNetworkRequests BEGIN DELETE FROM CacheAllowsAllNetworkRequests WHERE wildcard = NEW.wildcard AND cache = NEW.cache; END;
CREATE TRIGGER IF NOT EXISTS DisableCacheEntriesInsert AFTER INSERT ON CacheEntries BEGIN DELETE FROM CacheEntries WHERE cache = NEW.cache AND type = NEW.type AND resource = NEW.resource; END;
CREATE TRIGGER IF NOT EXISTS DisableCacheGroupsInsert AFTER INSERT ON CacheGroups BEGIN DELETE FROM CacheGroups WHERE id = NEW.id; END;
CREATE TRIGGER IF NOT EXISTS DisableCacheResourceDataInsert AFTER INSERT ON CacheResourceData BEGIN DELETE FROM CacheResourceData WHERE id = NEW.id; END;
CREATE TRIGGER IF NOT EXISTS DisableCacheResourcesInsert AFTER INSERT ON CacheResources BEGIN DELETE FROM CacheResources WHERE id = NEW.id; END;
CREATE TRIGGER IF NOT EXISTS DisableOriginsInsert AFTER INSERT ON Origins BEGIN DELETE FROM Origins WHERE origin = NEW.origin AND quota = NEW.quota; END;

@wallneradam
Copy link

You can simply disable cache by command line parameter:
phantomjs --disk-cahe=false --max-disk-cache-size=0 yourscript.js

I checked, I deleted the cache directory, and it is not created again. With this parameters.

@stale stale bot added the stale label Dec 26, 2019
@stale
Copy link

stale bot commented Dec 29, 2019

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

@stale stale bot closed this as completed Dec 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants