~/talk

Using unsafe.Pointer to explore Linux system calls

Talkat GoCon Canada 2019 · on Friday, 2019-05-31· [linux-and-operating-systems, c-and-cpp]
slides:none on file

Shows concrete patterns for using unsafe.Pointer with Linux syscalls: uses x/sys/unix and ioctl to fetch a uint32 vmsock context ID, demonstrates reinterpreting memory like convert uint16 to [2]byte via unsafe.Pointer and mapping a 328‑byte taskstats blob directly to a struct, warns that missing size checks to avoid reading arbitrary memory leaks secrets, and emphasizes the rule to convert the pointer to uintptr inside the syscall call to prevent GC-moving and crashes.

AI-written summary · about

  1. 0:00Introduction
  2. 0:50What is package unsafe
  3. 1:32What is a system call
  4. 2:37IOCTL system call example
  5. 3:18Prerequisites for unsafe system calls
  6. 3:38Go type safety explained
  7. 4:39Go types memory layout
  8. 5:40Slices and memory
  9. 6:21Endianness in Go
  10. 7:25Diving into package unsafe
  11. 8:07unsafe.Sizeof function
  12. 9:11unsafe.Pointer conversions
  13. 12:40Dangerous unsafe patterns
  14. 15:07Safe uses of unsafe
  15. 15:30System calls with syscall
  16. 16:55IOCTL in Go with syscall
  17. 17:58Garbage collector and pointers
  18. 18:40Native endianness detection
  19. 19:01Linux taskstats interface
  20. 20:03Performance with unsafe
  21. 20:45Other uses of unsafe
  22. 21:06Summary and responsibilities
  23. 21:52Q&A
~/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.