vibe-d / vibe.d

Official vibe.d development
MIT License
1.15k stars 284 forks source link

Crash under uncertain circumstances #1241

Closed mihails-strasuns closed 3 years ago

mihails-strasuns commented 9 years ago

Downstream issue : https://github.com/Dicebot/mood/issues/17

Debug log before crash:

FD: -1
FD: -1
FD: -1
FD: -1
FD: 60
FD: -1
FD: -1
start task (fd 60).
FD: -1
FD: 59
FD: -1
FD: -1
start task (fd 59).
FD: -1
FD: 61
FD: -1
FD: -1
start task (fd 61).
FD: -1
Accept TLS connection: server
Accept TLS connection: server
Accept TLS connection: server
Socket event on fd 60: 17 (7F7F10002DB8 vs 7F7F10002DB8)
Connection was closed (fd 60).
FD: 62
FD: -1
FD: -1
FD: -1
start task (fd 62).
FD: -1
Accept TLS connection: server
Exception occured on SSL source stream: object.Exception@../../.dub/packages/vibe-d-0.7.24/source/vibe/core/drivers/libevent2_tcp.d(385): Connection error while reading from TCPConnection.
----------------
./mood(void vibe.core.drivers.libevent2_tcp.Libevent2TCPConnection.read(ubyte[])+0x6e) [0x7f7f8e]
./mood(onBioRead+0x6f) [0x897597]
/usr/lib/libcrypto.so.1.0.0(BIO_read+0x6c) [0x7f7f16c6c5ec]
Error while writing the response: Connection error while reading from TCPConnection.
Exception while handling request GET /: object.Exception@../../.dub/packages/vibe-d-0.7.24/source/vibe/core/drivers/libevent2_tcp.d(385): Connection error while reading from TCPConnection.
----------------
./mood(void vibe.core.drivers.libevent2_tcp.Libevent2TCPConnection.read(ubyte[])+0x6e) [0x7f7f8e]
./mood(onBioRead+0x6f) [0x897597]
/usr/lib/libcrypto.so.1.0.0(BIO_read+0x6c) [0x7f7f16c6c5ec]
task out (fd 0).
task finished.
TCP close request false open
Segmentation fault (core dumped)

Checking core in gdb shows that ctx.core is null here:

.dub/packages/vibe-d-0.7.24/source/vibe/core/drivers/libevent2_tcp.d:687
687                 else ctx.core.resumeTask(ctx.writeOwner, ex);

(full bt in linked issue)

Nothing in backtrace or log seems to refer to anything from my application so I a bit lost about debugging it. Could be memory corruption, of course, but I wonder if something rings a bell immediately.

etcimon commented 9 years ago

If you're using DMD 2.068 you should know about the struct dtor issue I just posted about. Anything could be related to it right now

mihails-strasuns commented 9 years ago

Ahha, indeed, compiling the very same source with gdc (2.066) seems to work just fine.

Thanks for the heads up!

SerialVelocity commented 8 years ago

Hey, I don't think this is the 2.068 issue. I'm on 2.067 and I'm also having this issue (and I think I've had it before as well or at least a similar issue).

Easiest way to repro it is to open the app in gdb, set a breakpoint on "onSocketEvent", wait a few minutes, resume the thread. You will end up with a seg fault about 40% of the time because ctx.core is null.

I'm on a Mac btw

SerialVelocity commented 8 years ago

@Dicebot @etcimon @s-ludwig Oh, actually, this has been around for ages (see #1053 comment 3). Seems like a high-priority bug if it is causing segmentation faults and has been around since at least April.

s-ludwig commented 6 years ago

FWIW, this should be fixed in vibe-core/eventcore, as that explicitly keeps the the reference count incremented until it has received the expected read/write event, so that the underlying file descriptor and the associated data do not get destroyed prematurely.

Geod24 commented 3 years ago

Closing as per @s-ludwig 's comment.