Tag

Unsafe

1 views collected around this technical thread.

Go Programming World
Go Programming World
Mar 17, 2025 · Fundamentals

Exploring Go's //go:linkname Directive and Its Pull, Push, and Handshake Modes

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.

GoLinknameUnsafe
0 likes · 13 min read
Exploring Go's //go:linkname Directive and Its Pull, Push, and Handshake Modes
macrozheng
macrozheng
Jul 19, 2024 · Backend Development

Master Java Obfuscation: 5 Crazy Tricks to Write Unreadable Code

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.

JavaUnicodeUnsafe
0 likes · 12 min read
Master Java Obfuscation: 5 Crazy Tricks to Write Unreadable Code
Python Programming Learning Circle
Python Programming Learning Circle
Jul 15, 2024 · Fundamentals

Understanding NumPy Array Memory Layout and Accelerating Image Resizing with Unsafe Python Techniques

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.

NumPyPygameUnsafe
0 likes · 19 min read
Understanding NumPy Array Memory Layout and Accelerating Image Resizing with Unsafe Python Techniques
JD Retail Technology
JD Retail Technology
Apr 29, 2024 · Backend Development

Investigation of a Kafka Consumer Offset Anomaly Caused by Native C++ Memory Modification

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.

JavaKafkaMemory Corruption
0 likes · 7 min read
Investigation of a Kafka Consumer Offset Anomaly Caused by Native C++ Memory Modification
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Oct 5, 2023 · Backend Development

Mastering Java Unsafe: Low-Level Memory Tricks and Atomic Operations

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
Mastering Java Unsafe: Low-Level Memory Tricks and Atomic Operations
Cognitive Technology Team
Cognitive Technology Team
Aug 6, 2023 · Fundamentals

Common Pitfalls When Using Go Slices and How to Avoid Them

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.

BackendCopySlices
0 likes · 5 min read
Common Pitfalls When Using Go Slices and How to Avoid Them
Laravel Tech Community
Laravel Tech Community
Dec 12, 2022 · Fundamentals

Go 1.20 Release Candidate Highlights: New Slice‑to‑Array Conversion, Unsafe Package Functions, and Comparable Types

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.

ComparableGoGo1.20
0 likes · 4 min read
Go 1.20 Release Candidate Highlights: New Slice‑to‑Array Conversion, Unsafe Package Functions, and Comparable Types
macrozheng
macrozheng
Sep 6, 2022 · Backend Development

How to Write Java Code That Even Your Colleagues Can’t Understand

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.

JavaUnsafebitwise
0 likes · 14 min read
How to Write Java Code That Even Your Colleagues Can’t Understand
Code Ape Tech Column
Code Ape Tech Column
Jun 1, 2022 · Fundamentals

Understanding sun.misc.Unsafe: Construction, Core Functions, and Practical Use Cases

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
Understanding sun.misc.Unsafe: Construction, Core Functions, and Practical Use Cases
Tencent Cloud Developer
Tencent Cloud Developer
Apr 18, 2022 · Backend Development

Go Black Magic: Accessing Runtime Functions and Integrating C/Assembly for Performance

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.

GoUnsafeassembly
0 likes · 17 min read
Go Black Magic: Accessing Runtime Functions and Integrating C/Assembly for Performance
Zhuanzhuan Tech
Zhuanzhuan Tech
Mar 28, 2022 · Backend Development

Understanding Java's sun.misc.Unsafe: Construction, Core Functions, and Usage

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.

ConcurrencyJavaLow-level programming
0 likes · 12 min read
Understanding Java's sun.misc.Unsafe: Construction, Core Functions, and Usage
Top Architect
Top Architect
Jan 1, 2022 · Backend Development

Understanding ThreadLocalRandom and Unsafe in Java: Performance, Implementation, and Pitfalls

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.

ConcurrencyJDKJava
0 likes · 10 min read
Understanding ThreadLocalRandom and Unsafe in Java: Performance, Implementation, and Pitfalls
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Mar 31, 2021 · Fundamentals

Unlocking Java’s Unsafe: Access Low‑Level Memory and Concurrency Safely

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.

ConcurrencyJavaUnsafe
0 likes · 9 min read
Unlocking Java’s Unsafe: Access Low‑Level Memory and Concurrency Safely
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Sep 22, 2020 · Backend Development

Understanding AtomicInteger, CAS, and Lock‑Free Concurrency in Java

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.

AtomicIntegerCASConcurrency
0 likes · 15 min read
Understanding AtomicInteger, CAS, and Lock‑Free Concurrency in Java
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Jul 23, 2020 · Fundamentals

Understanding CAS, AtomicInteger, and Unsafe in Java Concurrency

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.

ABAAtomicIntegerCAS
0 likes · 15 min read
Understanding CAS, AtomicInteger, and Unsafe in Java Concurrency
Xiaokun's Architecture Exploration Notes
Xiaokun's Architecture Exploration Notes
Feb 4, 2020 · Fundamentals

Unlocking Java’s CAS: How Unsafe Powers Atomic Operations and Solves ABA

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.

AtomicCASConcurrency
0 likes · 10 min read
Unlocking Java’s CAS: How Unsafe Powers Atomic Operations and Solves ABA
Qunar Tech Salon
Qunar Tech Salon
Apr 9, 2019 · Fundamentals

Understanding Java Object Memory Layout and the Oop‑Klass Model

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.

HSDBInstrumentationJVM
0 likes · 15 min read
Understanding Java Object Memory Layout and the Oop‑Klass Model
Hujiang Technology
Hujiang Technology
Oct 29, 2018 · Backend Development

Implementing a Custom Java AQS Lock from Scratch

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
Implementing a Custom Java AQS Lock from Scratch