Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable client meta-data #662

Merged
merged 26 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/snmalloc/mem/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,9 @@ namespace snmalloc
*/
[[nodiscard]] SNMALLOC_FAST_PATH SlabMetadata* get_slab_metadata() const
{
//SNMALLOC_ASSERT(get_remote() != nullptr);
// TODO Following assertion removed for client meta-data use case.
// Think about possible UAF scenarios.
// SNMALLOC_ASSERT(get_remote() != nullptr);
mjp41 marked this conversation as resolved.
Show resolved Hide resolved
return unsafe_from_uintptr<SlabMetadata>(meta & ~META_BOUNDARY_BIT);
}
};
Expand Down
27 changes: 17 additions & 10 deletions src/test/func/miracle_ptr/miracle_ptr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
*
* Do not use as is.
*/
#ifdef SNMALLOC_THREAD_SANITIZER_ENABLED
int main()
{
return 0;
}
#else

#include "test/setup.h"
# include "test/setup.h"

#include <iostream>
#include <memory>
#include <snmalloc/backend/globalconfig.h>
#include <snmalloc/snmalloc_core.h>
# include <iostream>
# include <memory>
# include <snmalloc/backend/globalconfig.h>
# include <snmalloc/snmalloc_core.h>

namespace snmalloc
{
Expand All @@ -20,8 +26,8 @@ namespace snmalloc
using Alloc = snmalloc::LocalAllocator<snmalloc::StandardConfigClientMeta<
ArrayClientMetaDataProvider<std::atomic<size_t>>>>;
}
#define SNMALLOC_PROVIDE_OWN_CONFIG
#include <snmalloc/snmalloc.h>
# define SNMALLOC_PROVIDE_OWN_CONFIG
# include <snmalloc/snmalloc.h>

SNMALLOC_SLOW_PATH void error(std::string msg)
{
Expand Down Expand Up @@ -176,7 +182,7 @@ class raw_ptr

int main()
{
#ifndef SNMALLOC_PASS_THROUGH
# ifndef SNMALLOC_PASS_THROUGH
raw_ptr<int> p;
{
auto up = std::make_unique<int>(42);
Expand All @@ -188,6 +194,7 @@ int main()
// raw_ptr has kept the memory live.
// Current implementation zeros the memory when the unique_ptr is destroyed.
check(*p == 0, "Failed to keep memory live");
#endif
# endif
return 0;
}
}
#endif
Loading