yfinkelstein/node-zookeeper — Issue #30: Reproduceable SEGFAULT when using aw_* watcher methods on systems that GC ( long-running and / or memory pressure)
Author: ddopson
Created: 2011-12-21 17:43:22+00:00
State: open

I have some awesome debugging / repro data for this that I'll post a bit later (on a plane now). But the short of the story is that the code uses CALLBACK_EPILOG to fire watcher methods and that macro calls cb_destroy. So once a watcher has fired at least once, it becomes eligible for garbage collection. Well, this evil little bug doesn't repro in development because there usually isn't enough memory pressure to cause the watcher method to get GC'd. But in production ........ pure evil. Depending on load, minutes or hours later, GC will get around to freeing the watcher callback and the next time the watcher fires ..... segfault.

Posting this issue to track the problem. When I get a chance, I'll bang out a fix.

This is a huge bug and is likely to cause major pain (and only in production!!) for anyone that uses the aw_ methods.

If anyone is hitting this bug in production and wants a workaround, try this: create an array with refs to your watcher callback. Each time it fires, add another ref to the array.