1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-01 13:13:53 +00:00

Proper mmap failure detection.

This commit is contained in:
Bartosz Taudul 2021-12-04 18:58:17 +01:00
parent 22284d57e7
commit 6a0d233613
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -1,3 +1,5 @@
#include <errno.h>
namespace tracy namespace tracy
{ {
@ -14,8 +16,9 @@ public:
assert( __builtin_popcount( Size ) == 1 ); assert( __builtin_popcount( Size ) == 1 );
m_mapSize = Size + pageSize; m_mapSize = Size + pageSize;
auto mapAddr = mmap( nullptr, m_mapSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 ); auto mapAddr = mmap( nullptr, m_mapSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
if( !mapAddr ) if( mapAddr == MAP_FAILED )
{ {
TracyDebug( "mmap failed: errno %i (%s)\n", errno, strerror( errno ) );
m_fd = 0; m_fd = 0;
m_metadata = nullptr; m_metadata = nullptr;
close( fd ); close( fd );