Ticket #5 (closed defect: fixed)

Opened 1 year ago

Last modified 6 months ago

Assertion `nbytes > 0' failed error

Reported by: macournoyer Assigned to: raggi
Priority: major Milestone: EventMachine "Framework"
Keywords: Cc:

Description

Some users of Thin reported crashes with this in the logs:

ruby: ed.cpp:607: void ConnectionDescriptor::_WriteOutboundData(): Assertion `nbytes > 0' failed.

Any clue what's wrong?

Attachments

test_connection_without_send.rb (1.0 kB) - added by rogerdpack on 06/26/08 19:01:34.
example test which errs on OS X

Change History

06/17/08 14:10:20 changed by tmm1

06/26/08 17:08:08 changed by rogerdpack

I believe this is a kqueue bug [?] The test that causes it to fail is connecting to a server and writing nothing. EM is 'expecting it to write' immediately, as it arms it for writable immediately. I have, however, seen this in other circumstances, but that seems most obvious. The others were when it was under super heavy load for like a minute.

06/26/08 19:01:34 changed by rogerdpack

  • attachment test_connection_without_send.rb added.

example test which errs on OS X

06/30/08 20:18:33 changed by raggi

  • owner set to raggi.
  • status changed from new to assigned.

May be solved on a side track, see #40

06/30/08 20:25:06 changed by raggi

01/22/09 15:34:04 changed by tmm1

This patch fixes the issue. Will commit to git shortly:

diff --git a/ext/ed.cpp b/ext/ed.cpp
index 27e2d11..261e39c 100644
--- a/ext/ed.cpp
+++ b/ext/ed.cpp
@@ -189,9 +189,7 @@ ConnectionDescriptor::ConnectionDescriptor (int sd, EventMachine_t *em):
 	#ifdef HAVE_EPOLL
 	EpollEvent.events = EPOLLOUT;
 	#endif
-	#ifdef HAVE_KQUEUE
-	MyEventMachine->ArmKqueueWriter (this);
-	#endif
+	// 22Jan09: Moved ArmKqueueWriter into SetConnectPending() to fix assertion failure in _WriteOutboundData()
 }
 
 
@@ -263,6 +261,17 @@ int ConnectionDescriptor::ReportErrorStatus (const char *binding)
 	return -1;
 }
 
+/***************************************
+ConnectionDescriptor::SetConnectPending
+****************************************/
+
+void ConnectionDescriptor::SetConnectPending(bool f)
+{
+	bConnectPending = f;
+	#ifdef HAVE_KQUEUE
+	MyEventMachine->ArmKqueueWriter (this);
+	#endif
+}
 
 
 /**************************************
diff --git a/ext/ed.h b/ext/ed.h
index 815149f..b6729a4 100644
--- a/ext/ed.h
+++ b/ext/ed.h
@@ -139,7 +139,7 @@ class ConnectionDescriptor: public EventableDescriptor
 
 		int SendOutboundData (const char*, int);
 
-		void SetConnectPending (bool f) { bConnectPending = f; }
+		void SetConnectPending (bool f);
 
 		void SetNotifyReadable (bool readable) { bNotifyReadable = readable; }
 		void SetNotifyWritable (bool writable) { bNotifyWritable = writable; }

01/22/09 16:03:23 changed by tmm1

  • status changed from assigned to closed.
  • resolution set to fixed.