Initialize async member#337
Conversation
Initialize async member otherwise it may happen that in `FSEvents::asyncStart()` the check `async.data == this` is already `true` and as a result `uv_async_init()` is not called. Refs.: nodejs/node#34776 (comment)
|
thanks |
|
@pipobscure should we port this to 2.x? |
|
Not needed. v2.x has no cpp classes and no such checks so there is nowhere to port it to. And this could only be an issue here in 1.x in very very rare (almost theoretical circumstances) but it’s definitely an issue worth fixing because in the rare case where the uninitialised memory happens to contain the exact memory address of the object that’s just been created this would be a problem. Normally I’d say this is a one in a trillion chance, but when you consider potential memory reuse this could be more frequent, so a definite thank you to @Flarna for the catch! |
|
It depends on the algorithm used by the heap manager how likely this is. Quite frequently pools for small objects are used and it's likely to get the same location if you do new - delete - new for the same size. |
|
which is precisely why I love you catching it!!! Now we just have to migrate glob-watcher to v2.x so that we can stop having to worry about v1.x 😀 |
|
Don't know if 1.x is still published and how often. |
Initialize async member otherwise it may happen that in
FSEvents::asyncStart()the checkasync.data == thisis alreadytrueand as a resultuv_async_init()is not called.Refs.: nodejs/node#34776 (comment)