Permalink
Browse files

wip: debugging malloc errors

  • Loading branch information...
jferris committed Jul 20, 2012
1 parent 82b3921 commit 05e7d73bd27f2b3346cf69e26af52bcb4f859d1d
View
@@ -63,3 +63,9 @@ task :generate_command do
command_factory.sub!(/^$/, "#include \"#{name}.h\"\n")
File.open(command_factory_file_name, "w") { |file| file.write(command_factory) }
end
+
+desc "Remove built files"
+task :clean do
+ system('make clean')
+ system('git clean -fxd Makefile bin pkg src')
+end
View
@@ -0,0 +1,61 @@
+Received "Reset"
+Started "Reset"
+Finished "Reset" with response "Success()"
+Wrote response true ""
+Received "Visit"
+Started "Visit"
+Load started
+"Visit" started page load
+Started request to "http://127.0.0.1:52635/"
+webkit_server(2017,0x10d881000) malloc: *** error for object 0x1048c06a0: pointer being freed was not allocated
+*** set a breakpoint in malloc_error_break to debug
+Finished "Visit" with response "Success()"
+
+Received "Reset"
+Started "Reset"
+Finished "Reset" with response "Success()"
+Wrote response true ""
+Received "Visit"
+Started "Visit"
+Load started
+"Visit" started page load
+Started request to "http://127.0.0.1:54222/"
+webkit_server(2651,0x10ee52000) malloc: *** error for object 0x10a9110b0: pointer being freed was not allocated
+*** set a breakpoint in malloc_error_break to debug
+
+
+Received "Reset"
+Started "Reset"
+Finished "Reset" with response "Success()"
+Wrote response true ""
+Received "Visit"
+Started "Visit"
+Load started
+"Visit" started page load
+Started request to "http://127.0.0.1:53053/"
+Finished "Visit" with response "Success()"
+
+Program received signal EXC_BAD_ACCESS, Could not access memory.
+Reason: KERN_INVALID_ADDRESS at address: 0x000000010c5b70fe
+
+#0 0x00007fff8897e6c0 in malloc_error_break ()
+#1 0x00007fff8897e805 in free ()
+#2 0x000000010315bd3e in QString::free ()
+#3 0x00000001031c2c29 in QUrlPrivate::authority ()
+#4 0x00000001031ca002 in QUrlPrivate::toEncoded ()
+#5 0x00000001031cb0a4 in QUrlPrivate::validate ()
+#6 0x00000001031cb305 in QUrl::port ()
+#7 0x0000000102faaedb in QHttpThreadDelegate::startRequest ()
+#8 0x0000000103012c1b in QHttpThreadDelegate::qt_static_metacall ()
+#9 0x000000010322f861 in QObject::event ()
+#10 0x00000001022fbfad in QApplicationPrivate::notify_helper ()
+#11 0x0000000102302fe4 in QApplication::notify ()
+#12 0x000000010321b75c in QCoreApplication::notifyInternal ()
+#13 0x000000010321d380 in QCoreApplicationPrivate::sendPostedEvents ()
+#14 0x0000000103250832 in QEventDispatcherUNIX::processEvents ()
+#15 0x000000010321a664 in QEventLoop::processEvents ()
+#16 0x000000010321aa14 in QEventLoop::exec ()
+#17 0x0000000103105198 in QThread::exec ()
+#18 0x00000001031085aa in QThreadPrivate::start ()
+#19 0x00007fff8892c8bf in _pthread_start ()
+#20 0x00007fff8892fb75 in thread_start ()
@@ -13,7 +13,8 @@ def initialize(options = {})
@socket_class = options[:socket_class] || TCPSocket
@stdout = options.has_key?(:stdout) ? options[:stdout] : $stdout
@command = options[:command] || SERVER_PATH
- start_server
+ # start_server
+ @port = 12345
connect
end
View
@@ -43,6 +43,7 @@ def in_iframe_request?
before do
driver.visit("/")
+ pending
end
it "finds frames by index" do
@@ -182,6 +183,7 @@ def in_iframe_request?
"css"
end
end
+ pending
end
before { driver.visit("/") }
@@ -279,6 +281,7 @@ def in_iframe_request?
end
it "does not double-encode URLs" do
+ pending
driver.visit("/hello/world?success=%25true")
driver.current_url.should =~ /success=\%25true/
end
@@ -1777,11 +1780,13 @@ def which_for(character)
describe "logger app" do
it "logs nothing before turning on the logger" do
+ pending
driver.visit("/")
log.should == ""
end
it "logs its commands after turning on the logger" do
+ pending
driver.enable_logging
driver.visit("/")
log.should_not == ""
View
@@ -0,0 +1,27 @@
+require 'spec_helper'
+require 'capybara/webkit/driver'
+
+describe Capybara::Webkit::Driver do
+ include AppRunner
+
+ context "malloc app" do
+ let(:driver) do
+ driver_for_html "<html><body>#{nest_tags}</body></html>"
+ end
+
+ it "generates a malloc error" do
+ 100_000.times do
+ driver.visit "/"
+ driver.reset!
+ end
+ end
+
+ def nest_tags(count = 1000)
+ if count == 0
+ 'text'
+ else
+ "<p>#{nest_tags(count - 1)}</p>"
+ end
+ end
+ end
+end
View
@@ -22,7 +22,7 @@
end
require 'capybara/webkit'
-connection = Capybara::Webkit::Connection.new(:socket_class => TCPSocket, :stdout => nil)
+connection = Capybara::Webkit::Connection.new(:socket_class => TCPSocket)
$webkit_browser = Capybara::Webkit::Browser.new(connection)
if ENV['DEBUG']
@@ -42,7 +42,7 @@ void PageLoadingCommand::pageLoadingFromCommand() {
void PageLoadingCommand::commandFinished(Response *response) {
disconnect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
- m_manager->logger() << "Finished" << m_command->toString();
+ m_manager->logger() << "Finished" << m_command->toString() << "with response" << response->toString();
m_command->deleteLater();
if (m_pageLoadingFromCommand)
m_pendingResponse = response;
View
@@ -22,3 +22,7 @@ bool Response::isSuccess() const {
QByteArray Response::message() const {
return m_message;
}
+
+QString Response::toString() const {
+ return QString(m_success ? "Success(" : "Failure(") + m_message + ")";
+}
View
@@ -8,6 +8,7 @@ class Response {
Response(bool success);
bool isSuccess() const;
QByteArray message() const;
+ QString toString() const;
private:
bool m_success;
View
@@ -10,7 +10,7 @@ Server::Server(QObject *parent) : QObject(parent) {
bool Server::start() {
connect(m_tcp_server, SIGNAL(newConnection()), this, SLOT(handleConnection()));
- return m_tcp_server->listen(QHostAddress::LocalHost, 0);
+ return m_tcp_server->listen(QHostAddress::LocalHost, 12345);
}
quint16 Server::server_port() const {
View
@@ -7,7 +7,8 @@ Visit::Visit(WebPageManager *manager, QStringList &arguments, QObject *parent) :
}
void Visit::start() {
- QUrl requestedUrl = QUrl::fromEncoded(arguments()[0].toUtf8(), QUrl::StrictMode);
- page()->currentFrame()->load(QUrl(requestedUrl));
+ QString urlString = QString(arguments()[0].toUtf8());
+ QUrl requestedUrl = QUrl(urlString, QUrl::StrictMode);
+ page()->currentFrame()->load(requestedUrl);
emit finished(new Response(true));
}
View
@@ -124,6 +124,7 @@ void WebPage::frameCreated(QWebFrame * frame) {
}
void WebPage::injectJavascriptHelpers() {
+ qDebug() << "injectJavascriptHelpers";
QWebFrame* frame = qobject_cast<QWebFrame *>(QObject::sender());
frame->evaluateJavaScript(m_capybaraJavascript);
}
View
@@ -6,7 +6,7 @@ WebPageManager::WebPageManager(QObject *parent) : QObject(parent) {
m_ignoreSslErrors = false;
m_cookieJar = new NetworkCookieJar(this);
m_success = true;
- m_loggingEnabled = false;
+ m_loggingEnabled = true;
m_ignoredOutput = new QString();
createPage(this)->setFocus();
}
@@ -86,6 +86,7 @@ bool WebPageManager::ignoreSslErrors() {
}
void WebPageManager::reset() {
+ qDebug() << "reset";
m_cookieJar->clearCookies();
m_pages.first()->deleteLater();
m_pages.clear();
View
@@ -110,6 +110,6 @@ SOURCES = \
RESOURCES = webkit_server.qrc
QT += network webkit
-CONFIG += console
+CONFIG += console debug/release debug
CONFIG -= app_bundle

0 comments on commit 05e7d73

Please sign in to comment.