Alignment issues when using database mmapped from a file
- Dominant language
- C++
- Stars
- 5.5k
- Forks
- 816
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 2
Description
I have received several reports from Rspamd users about crashes when using Hyperscan database that is mmapped from a file (to reduce memory footprint when using the same database from multiple workers). One of the reports with some details could be found [here](https://github.com/rspamd/rspamd/issues/4329).
In general, I [load](https://github.com/rspamd/rspamd/blob/master/src/libserver/hyperscan_tools.cxx#L303) a serialized database, then [dump](https://github.com/rspamd/rspamd/blob/master/src/libserver/hyperscan_tools.cxx#L317) it to a memory buffer (properly aligned) and then [mmap](https://github.com/rspamd/rspamd/blob/master/src/libserver/hyperscan_tools.cxx#L380) and cast to hs_database_t. The pointer of the database itself is properly aligned on page boundary as guaranteed by mmap. So far, I'm not quite sure about what's going on in this case.
Contributor guide
Assessment
This issue has not been assessed yet.