You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's sentry_malloc and sentry_free functions. It is expected that they're the only ones used for memory allocation and free operations.
However, for example in this code:
So the pointer is allocated with MPACK_MALLOC aka malloc, but getting freed with sentry_free.
When does the problem happen
During build
During run-time
When capturing a hard crash
Environment
OS: [e.g. Windows 10, 64-bit] Windows 10, 64-bit
Compiler: [e.g. MSVC 19] MSVC 19.31.31104.0
CMake version and config: 3.22.22022201-MSVC_2, -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=OFF -DSENTRY_LIBRARY_TYPE=STATIC
-- SENTRY_TRANSPORT=winhttp
-- SENTRY_BACKEND=crashpad
-- SENTRY_LIBRARY_TYPE=SHARED
Steps To Reproduce
See #606 (comment)
What I did was commenting out these functions and then implementing them in a different library, that in turn getting successfully linked.
But on runtime, when sentry_free is called in
with a custom free function on a pointer it doesn't recognize, it fails.
I cannot paste the exact code, as the allocator is specific to the game engine and I'm not sure if the behavior would be the same with all allocators.
Proposed fix
It seems that replacing these macros with sentry_ functions does fix my crash.
Inserting the changes above the only import of vendor/mpack.h I could find did not help, so I simply just did those somewhere at the top of my vendor/mpack.h:
Note that sentry_realloc didn't exist and I created it in my copy as well.
But creating sentry_realloc and defining MPACK_REALLOCisn't really needed, since the mpack header will just create its own realloc if it's missing, so you could do just fine skipping that one.
The text was updated successfully, but these errors were encountered:
Description
There's
sentry_malloc
andsentry_free
functions. It is expected that they're the only ones used for memory allocation and free operations.However, for example in this code:
sentry-native/src/backends/sentry_backend_crashpad.cpp
Lines 85 to 92 in 757a7b8
the usage is inconsistent. When
sentry_value_to_msgpack
is called, it callsmpack_writer_init_growable
, that usesMPACK_MALLOC
, which is defined as:sentry-native/vendor/mpack.h
Lines 204 to 206 in 757a7b8
So the pointer is allocated with
MPACK_MALLOC
akamalloc
, but getting freed withsentry_free
.When does the problem happen
Environment
-- SENTRY_TRANSPORT=winhttp
-- SENTRY_BACKEND=crashpad
-- SENTRY_LIBRARY_TYPE=SHARED
Steps To Reproduce
See #606 (comment)
What I did was commenting out these functions and then implementing them in a different library, that in turn getting successfully linked.
But on runtime, when sentry_free is called in
sentry-native/src/backends/sentry_backend_crashpad.cpp
Line 92 in 757a7b8
I cannot paste the exact code, as the allocator is specific to the game engine and I'm not sure if the behavior would be the same with all allocators.
Proposed fix
It seems that replacing these macros with sentry_ functions does fix my crash.
Inserting the changes above the only import of
vendor/mpack.h
I could find did not help, so I simply just did those somewhere at the top of myvendor/mpack.h
:Note that
sentry_realloc
didn't exist and I created it in my copy as well.But creating
sentry_realloc
and definingMPACK_REALLOC
isn't really needed, since the mpack header will just create its own realloc if it's missing, so you could do just fine skipping that one.The text was updated successfully, but these errors were encountered: