Skip to content

Instantly share code, notes, and snippets.

Kevin Gosse kevingosse

Block or report user

Report or block kevingosse

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View hook.cs
using System;
using System.IO;
using System.Text;
internal class StartupHook
{
public static void Initialize()
{
Console.SetOut(new FixCasingTextWriter(Console.Out));
}
View checkGCKeywords.sh
#!/bin/bash
offset="0x"$(nm -C $2/libcoreclr.so | grep GCEventStatus::enabledLevels | cut -d ' ' -f1)
module="0x"$(cat /proc/$1/maps | grep -m 1 libcoreclr.so | cut -d '-' -f1)
dd bs=1 skip="$(($module + $offset))" count=8 status=none if="/proc/$1/mem" | od -An -vtu4
View gceventstatus.cpp
Volatile<GCEventLevel> GCEventStatus::enabledLevels[2] = {GCEventLevel_None, GCEventLevel_None};
Volatile<GCEventKeyword> GCEventStatus::enabledKeywords[2] = {GCEventKeyword_None, GCEventKeyword_None};
View gceventstatus.h
__forceinline static bool IsEnabled(GCEventProvider provider, GCEventKeyword keyword, GCEventLevel level)
{
assert(level >= GCEventLevel_None && level < GCEventLevel_Max);
size_t index = static_cast<size_t>(provider);
return (enabledLevels[index].LoadWithoutBarrier() >= level)
&& (enabledKeywords[index].LoadWithoutBarrier() & keyword);
}
View gceventstatus.h
inline bool GCEventEnabled##name() { return GCEventStatus::IsEnabled(provider, keyword, level); }
View gceventstatus.h
#define EVENT_ENABLED(name) GCEventEnabled##name()
View gc.cpp
#if defined(FEATURE_EVENT_TRACE)
// We are explicitly checking whether the event is enabled here.
// Unfortunately some of the ETW macros do not check whether the ETW feature is enabled.
// The ones that do are much less efficient.
if (EVENT_ENABLED(GCAllocationTick_V3))
{
fire_etw_allocation_event (etw_allocation_running_amount[etw_allocation_index], gen_number, acontext->alloc_ptr);
}
#endif //FEATURE_EVENT_TRACE
View Program.cs
class Program
{
public static async Task ProcessAsync()
{
await Task.Delay(2000);
Console.WriteLine("Processing done");
}
static async Task Main(string[] args)
{
View Program.cs
class Program
{
private static ManualResetEventSlim _mutex = new ManualResetEventSlim();
public static async Task Deadlock()
{
await ProcessAsync();
_mutex.Wait();
}
View Program.cs
var cts = new CancellationTokenSource();
cts.Token.Register(() => Thread.Sleep(5000));
cts.Cancel(); // This call will block during 5 seconds
You can’t perform that action at this time.