Tagged articles
Unsafe
46 articles · Page 1 of 1
After upgrading to JDK 27, Lombok 1.18.48 emits four Unsafe warnings during compilation because it uses sun.misc.Unsafe to bypass module access checks; the Lombok team won't fix it to preserve zero-config usability, but adding --sun-misc-unsafe-memory-access=allow to the forked compiler JVM silences the warnings.
Annotation ProcessingBuild ConfigurationCompiler Plugin
0 likes · 15 min read

This article explains Java's volatile and CAS primitives, detailing volatile's visibility and ordering guarantees, the memory barriers the JVM inserts, CAS's atomic compare‑and‑swap operation, common pitfalls like the ABA problem, and how their combination enables lock‑free thread safety, with code examples and interview tips.
CASConcurrencyHappens-Before
0 likes · 9 min read

The article examines Go’s claim of eradicating undefined behavior, showing that while the language defines many formerly UB cases such as integer overflow and out‑of‑bounds access, it still harbors UB in concurrent data races, interface type confusion, and certain unspecified behaviors.
ConcurrencyData RaceGo
0 likes · 18 min read

This article walks through five production‑grade Go unsafe techniques—including zero‑copy string conversion, deep struct copying, lock‑free queues, memory‑mapped files, and custom serialization—explaining core concepts, providing benchmark results, and offering a detailed safety checklist to avoid common pitfalls.
GoUnsafezero-copy
0 likes · 20 min read

The article explains CVE‑2025‑68260, the first Rust‑based vulnerability in the Linux kernel, detailing the race condition in the rust_binder driver, why the bug proves Rust’s safety promises, and how its limited impact contrasts with countless C‑related kernel CVEs.
CVEConcurrencyLinux kernel
0 likes · 7 min read

This article explains how Go's concurrent mark‑sweep garbage collector can become a bottleneck in high‑performance scenarios and provides practical techniques—such as using sync.Pool, avoiding unnecessary pointers, pre‑allocating memory, and applying zero‑copy and unsafe tricks—to dramatically lower GC overhead and improve overall program speed.
GCGoJSON
0 likes · 8 min read

This article explains the Go //go:linkname compiler directive, showing how it can link exported and unexported symbols across packages using Pull, Push, and Handshake modes, provides code examples, discusses safety considerations, and offers guidance for using the directive in Go 1.23 and later.
LinknamePull ModeUnsafe
0 likes · 13 min read

The article investigates Go 1.22’s claim that simple type casting []byte(str) can replace unsafe‑based string‑to‑byte conversions, presents four implementation variants, runs detailed benchmarks on macOS M2 and Linux amd64, analyses compiler inlining and escape behavior, and explains the hidden pitfalls of capacity and mutability in the k8s shortcut.
GoUnsafebenchmark
0 likes · 16 min read
![Why Go 1.22’s []byte(str) Conversion Beats Unsafe: Benchmarks and Deep Dive](https://wsrv.nl/?url=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2F0qAgGEpTiazFkfxZp5EpheUIPVgsaAKugqmDTQvuGcG9iap7wJtUPHtl26ESJv0LBiahUjCv6PRbLBxvTTm3KZddQ%2F0%3Fwx_fmt%3Djpeg)
This article demonstrates step‑by‑step how Go's reflection and unsafe packages can be leveraged to bypass the language's encapsulation, allowing reading, writing, and even assigning unaddressable private struct fields by manipulating internal flag bits and using low‑level pointer tricks.
GoReflectionStruct
0 likes · 13 min read

This article examines why Go's garbage collector can become a CPU bottleneck with large heaps, demonstrates the performance impact with benchmark programs, and presents practical strategies—such as using pointer‑free allocations, mmap‑backed memory, and string interning—to dramatically reduce GC pause times.
GoLarge heapUnsafe
0 likes · 13 min read

This article reveals five advanced Java tricks—using Unicode escapes in comments, over‑complicating simple logic with bitwise shifts, tampering with Boolean.TRUE via reflection, forcing both branches of an if‑else to run, and leveraging the Unsafe class for low‑level memory manipulation—to deliberately make code hard to understand.
JavaReflectionUnicode
0 likes · 12 min read

This article explains how NumPy stride differences caused a 100× slowdown when resizing images from a pygame Surface, demonstrates how to reinterpret the underlying memory layout using ctypes to achieve a 100× speedup with OpenCV, and discusses the safety implications of such low‑level Python tricks.
Memory LayoutNumPyOpenCV
0 likes · 19 min read

This article explains Go's uintptr type, its definition, typical scenarios such as cgo interaction and system calls, provides Linux and Windows code examples, and highlights key differences from regular pointers to help developers use it safely and effectively.
GoLow-Level ProgrammingUnsafe
0 likes · 6 min read

This article details a Kafka consumer issue where the offset unexpectedly becomes a large timestamp due to a native C++ method altering JVM memory, explains the debugging steps, reproduces the bug with Java code, and highlights the risks of unsafe native interactions.
JavaKafkaNative
0 likes · 7 min read

This article explains Go's unsafe package, covering its core concepts—Pointer, Sizeof, and Offsetof—provides practical code examples, outlines suitable scenarios such as system calls and performance tuning, and highlights the associated risks and best‑practice precautions.
GoMemorySystems Programming
0 likes · 5 min read

This article introduces Java's sun.misc.Unsafe class, explains its memory, CAS, thread, class, and object manipulation APIs, shows how to obtain an Unsafe instance, and provides practical code examples for low‑level operations such as field offsets, compare‑and‑swap, object allocation, and custom atomic counters.
ConcurrencyJavaLow-Level Programming
0 likes · 9 min read

This article explains three typical pitfalls of Go slices—ignoring the slice returned by append, unintentionally sharing the underlying array which can cause memory leaks, and the value‑copy behavior of for‑range loops—while also showing how to inspect slice internals using unsafe pointers.
BackendCOPYGo
0 likes · 5 min read


21CTOMar 31, 2023 · Backend Development
This article presents six practical Go performance optimizations—including GOMAXPROCS tuning for Kubernetes, struct field ordering, garbage‑collection limits, zero‑copy unsafe conversions, jsoniter usage, and sync.Pool pooling—that together can dramatically lower CPU, memory, and latency in production services.
GoKubernetesUnsafe
0 likes · 9 min read

This article explains the internal differences of Java's String implementation from JDK 8 to JDK 9+, demonstrates how to use sun.misc.Unsafe and trusted MethodHandles.Lookup to build zero‑copy String objects, and provides practical code examples for high‑performance string handling.
MethodHandlesStringUnsafe
0 likes · 12 min read


21CTODec 19, 2022 · Fundamentals
The article outlines Rust's 2023 priorities, emphasizing governance and leadership challenges, a potential compiler rewrite, strengthening Cargo, advancing async and unsafe programming, and fostering innovation while avoiding stagnation, all aimed at sustaining the language's reliability and performance.
CargoProgramming LanguageUnsafe
0 likes · 7 min read

Go 1.20 RC1 introduces experimental RISC‑V/FreeBSD support, expands slice‑to‑array conversion, adds three new unsafe package functions, updates comparable type constraints, and changes struct value comparison order, while being the final version compatible with macOS 10.13/10.14, with download details provided.
ComparableProgramming LanguageRISC-V
0 likes · 4 min read

Explore a series of unconventional Java tricks—from Unicode escape hacks and bitwise tricks to reflection-based Boolean tampering and Unsafe memory manipulation—that let you deliberately obfuscate code, making it hard for teammates to read, modify, or even predict its behavior.
JavaReflectionUnsafe
0 likes · 14 min read

This article explains the fundamentals of Compare‑And‑Swap (CAS), its implementation in Java through the Unsafe class, demonstrates AtomicInteger's lock‑free operations, and discusses CAS drawbacks such as spin‑wait overhead, single‑variable limitation, and the ABA problem with mitigation strategies.
ABA problemCASUnsafe
0 likes · 15 min read


ITPUBJun 30, 2022 · Backend Development
This article presents a layered approach to Go performance optimization, covering reasonable code practices, deliberate algorithmic and structural improvements, risky low‑level tweaks, and practical profiling techniques such as pprof, flame graphs, and trace, while providing concrete examples and actionable guidance.
GoSlice CapacityUnsafe
0 likes · 17 min read

This article explains the purpose, construction, and key functionalities of Java's sun.misc.Unsafe class, covering memory management, object allocation, class definition, offset handling, array operations, thread scheduling, CAS, and memory fences, while also showing how to obtain an Unsafe instance via reflection.
ConcurrencyJavaLow-Level Programming
0 likes · 11 min read

This article demonstrates three Go black‑magic techniques—using go:linkname to call private runtime functions like memmove and growslice, employing cgo to invoke C code, and embedding Plan 9 assembly—to bypass safety checks and achieve significant performance improvements, though they rely on unsafe practices.
GoUnsafecgo
0 likes · 17 min read

This article explains the purpose, construction, and most important capabilities of Java's sun.misc.Unsafe class—including memory management, object instantiation, class loading, offset handling, array operations, thread scheduling, CAS, and memory fences—while providing code examples and practical guidance for developers.
JavaLow-Level ProgrammingUnsafe
0 likes · 12 min read

This article explores Java's sun.misc.Unsafe class, detailing its construction, key capabilities such as low‑level memory management, object instantiation, class loading, CAS operations, and thread scheduling, while highlighting safety concerns and appropriate usage scenarios.
CASJavaLow-Level Programming
0 likes · 12 min read

This article examines Java's Random performance issues under high concurrency, explains how ThreadLocalRandom uses Unsafe for per‑thread seeds, explores the safety implications of native memory operations, and answers common questions about its design and memory layout.
ConcurrencyJavaMemory
0 likes · 10 min read

This article examines Java's Random performance limitations, explains how ThreadLocalRandom leverages the Unsafe class for per‑thread seed management, analyzes the underlying native methods, discusses safety concerns and memory layout, and shares practical code examples and insights for high‑concurrency applications.
ConcurrencyJDKThreadLocalRandom
0 likes · 10 min read

Go 1.17, now officially released, brings roughly a 5% performance uplift, a 2% reduction in amd64 binary size, adds native Windows ARM64 support, introduces pruned module graphs to streamline dependencies, and expands unsafe package capabilities with slice‑to‑array pointer conversion, unsafe.Add, and unsafe.Slice.
ARM supportGo 1.17Unsafe
0 likes · 3 min read

This article explores the performance drawbacks of java.util.Random in high‑concurrency scenarios, explains how ThreadLocalRandom leverages Unsafe for per‑thread seeds, examines native getLong/putLong operations, and discusses memory layout nuances such as compressed oops and potential pitfalls.
ConcurrencyJavaThreadLocalRandom
0 likes · 10 min read

This article examines Java's Random performance issues in high‑concurrency environments, explains how ThreadLocalRandom leverages sun.misc.Unsafe for lock‑free per‑thread seeds, and explores the associated memory layout, safety concerns, and practical code examples.
ThreadLocalRandomUnsaferandom
0 likes · 10 min read

This article explains the purpose and risks of Java's sun.misc.Unsafe class, categorizes its APIs, demonstrates how to obtain an Unsafe instance, and provides practical code examples for memory manipulation, CAS operations, thread control, object allocation, and building simple atomic utilities.
Unsafeatomic-operationslow-level memory
0 likes · 9 min read

This article demonstrates how to determine Go's endianness using unsafe.Pointer and uintptr, explains the memory layout of multi‑byte variables, and details the roles of *T, unsafe.Pointer, and uintptr for pointer arithmetic with concrete code examples.
GoUnsafebyte order
0 likes · 5 min read

This article explains Go’s type size specifications and alignment guarantees, demonstrates how to compute a struct’s memory footprint using unsafe.Sizeof and unsafe.Alignof, walks through concrete examples with structs T and R, and shows how field ordering affects actual memory usage.
GoUnsafealignof
0 likes · 12 min read

This article explains how Java's AtomicInteger and related atomic classes provide lock‑free thread‑safe operations to replace non‑atomic constructs like i++, detailing their inheritance, underlying Unsafe mechanisms, CAS implementation, memory barriers, optimistic locking, the ABA problem, and practical code examples for increment, decrement, and custom CAS‑based locks.
CASConcurrencyJava
0 likes · 15 min read

A PLDI'20 study of open‑source Rust projects shows that while Rust’s safe code effectively prevents most memory errors, many bugs still stem from unsafe blocks, and even safe code can suffer thread‑safety issues, highlighting the need for better tooling and developer awareness.
RustUnsafememory safety
0 likes · 14 min read

This article explains Java's memory model, the limitations of synchronized and volatile, introduces the java.util.concurrent.atomic package, details the CAS algorithm, the role of the Unsafe class, common pitfalls like the ABA problem, and presents code examples and solutions such as AtomicStampedReference.
ABACASConcurrency
0 likes · 15 min read

This article explains Java's Unsafe class, its low‑level memory operations, how Compare‑and‑Swap (CAS) is implemented via Unsafe, and how AtomicInteger leverages CAS for lock‑free thread safety while also covering the ABA problem and its mitigation.
CASConcurrencyJava
0 likes · 9 min read

This article explains the Compare‑and‑Swap (CAS) mechanism, its hardware‑level implementation via Java’s Unsafe class, provides sample code for basic CAS, atomic adders, custom atomic types, analyzes the ABA problem, and presents solutions such as versioned stamps and AtomicStampedReference.
CASJavaUnsafe
0 likes · 10 min read


JavaEdgeJan 4, 2020 · Backend Development
This article explains how Java’s Unsafe class provides low‑level park and unpark methods, how the LockSupport utility wraps them for easier use, and demonstrates building a simple exclusive lock with AbstractQueuedSynchronizer, covering state handling, blocking mechanisms, and thread‑queue management.
AQSConcurrencyCustomLock
0 likes · 7 min read

This article explains the JVM Oop‑Klass model, details how Java objects are represented in heap memory, shows how to calculate their size using source code analysis, HSDB, Instrumentation, Unsafe, and third‑party tools, and provides practical examples and code snippets.
HSDBJVMJava
0 likes · 15 min read

The article explains Java’s sun.misc.Unsafe class, detailing how to safely obtain its singleton instance, describing its low‑level memory, CAS, thread, class, and object operations, and outlining common high‑performance use cases while warning about the significant risks of misuse.
ConcurrencyJavaUnsafe
0 likes · 19 min read

This tutorial walks through building a simple Java lock using AbstractQueuedSynchronizer (AQS), starting with a basic MyLock class, adding thread parking with Unsafe, creating a FIFO thread container, and refining lock and unlock methods to achieve correct synchronization and avoid lock starvation.
AQSConcurrencyJava
0 likes · 15 min read

This article explores Swift's memory model and pointer mechanics, explains how HandyJSON converts JSON to class instances without runtime support, demonstrates MemoryLayout utilities, and shows practical techniques for modifying struct and class properties directly in memory.
JSON parsingMemory LayoutSWIFT
0 likes · 17 min read
