intercept / intercept-database

A database library for Intercept
MIT License
14 stars 9 forks source link

theading: Fix segfault in onCleanup #30

Closed mcoffin closed 2 years ago

mcoffin commented 2 years ago

On some platforms, deleting elements from std::map::iterator while iterating through it can cause a segfault.

The reason being that calling erase() invalidates the iterator(s). This was observed to cause a problem when running intercept code on Windows 10 Server.

Despite this (apparently) not being an issue due to implementation details with g++ 11 and the MSVC runtimes on Win10 Home/Pro, this was a usage of undefined behavior, and removing it resolves the issue we observed on Win10 server.

dedmen commented 2 years ago

OMG!!! I love you dude! This probably caused a long standing obscure bug of freeze/failing to process requests that I couldn't diagnose

Matt Coffin @.***> schrieb am Sa., 11. Dez. 2021, 22:11:

On some platforms, deleting elements from std::map::iterator while iterating through it can cause a segfault.

The reason being that calling erase() invalidates the iterator(s). This was observed to cause a problem when running intercept code on Windows 10 Server.

Despite this (apparently) not being an issue due to implementation details with g++ 11 and the MSVC runtimes on Win10 Home/Pro, this was a usage of undefined behavior, and removing it resolves the issue we observed on Win10 server.

You can view, comment on, or merge this pull request online at:

https://github.com/intercept/intercept-database/pull/30 Commit Summary

File Changes

(1 file https://github.com/intercept/intercept-database/pull/30/files)

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/intercept/intercept-database/pull/30, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4X6ZMLVLJH3FASVK7VPTDUQO5BRANCNFSM5J3NVFNA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.