emcrisostomo / fswatch

A cross-platform file change monitor with multiple backends: Apple OS X File System Events, *BSD kqueue, Solaris/Illumos File Events Notification, Linux inotify, Microsoft Windows and a stat()-based backend.
https://emcrisostomo.github.io/fswatch/
GNU General Public License v3.0
5.02k stars 327 forks source link

Assertion failed on fsw_destroy_session #74

Closed gsamokovarov closed 9 years ago

gsamokovarov commented 9 years ago

Hello there,

I'm getting Assertion failed: (ec == 0), function unlock, file /SourceCache/libcxx/libcxx-120/src/mutex.cpp, line 45 when I try to free a C API monitor session in short time after creation.

I have this snippet that always reproduces the problem on my machine:

#include <libfswatch/c/libfswatch.h>

int main(int argc, char *argv[])
{
  for (int i = 0; i < 10000; i++) {
    FSW_HANDLE handle = fsw_init_session();
    fsw_destroy_session(handle);
  }
}
emcrisostomo commented 9 years ago

Hi @gsamokovarov,

Thanks for the bug report. I've spotted the error in fsw_destroy_session: you can grab the develop branch if you are in a hurry: I'm preparing a release this afternoon or tomorrow and I'll close this issue afterwards.

gsamokovarov commented 9 years ago

I tried the fix and it works for me. Thank you @emcrisostomo!