~/talk

Introduction to unsafe C#: Calling native code and crashing in entirely new ways

Talkat NDC Porto 2023 · 2023-10-16..10-20· [rust]
links:none on file
slides:none on file

Shows how C# can use pointers, fixed and stackalloc to mutate memory (yes even mutating supposedly immutable strings), explain packing/explicit layout and unions, and call native libraries via P/Invoke. Demonstrates building a minimal SQLite wrapper using SafeHandle and NativeMemory/HeapAlloc that works, then reproduces crashes: buffer overflows, dangling delegate kills process when GC collects callback thunks, and fixes via unmanaged function pointers and SafeHandle reference counting. Gives concrete signatures, marshalling notes and platform calling‑convention caveats.

AI-written summary · about

  1. 0:00Welcome
  2. 0:45Why call native code
  3. 2:12Unsafe C# basics
  4. 5:23New kinds of bugs
  5. 9:16Unsafe features & examples
  6. 15:34Pointer arithmetic
  7. 21:32Memory layout & struct packing
  8. 29:39Platform Invoke
  9. 36:30Calling conventions
  10. 38:56Safe handles
  11. 45:42Native callbacks
  12. 51:44Function pointers
  13. 54:12Further resources
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.