Memory Segment Views for Safe Native Library Access

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Java programs face challenges in runtime safety when interacting with native libraries, as they may return memory addresses with unknown spatial and temporal bounds, leading to potential out-of-bounds or deallocated memory access issues.

Innovation Solution

A memory access API is introduced that uses memory segment views to limit access to memory addresses, specifying spatial and temporal bounds, and an 'everything segment' is defined to cover the entire native heap, ensuring safe dereferencing of unknown memory addresses.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If a Java program directly accesses memory addresses returned by native libraries, then the program can interact with native code functionality, but the program risks performing unsafe memory access to out-of-bounds or deallocated memory locations

Engineering Contradiction:
Improveability to interact with native librariesVSAvoidruntime safety
Core Design Contradiction:
Adaptability or versatilityVSReliability

Solution Approach 1:

The patent introduces a memory segment view as an intermediary layer between the Java program and native memory addresses. This mediator object encapsulates the raw memory address and provides controlled access through dereference operations, automatically performing bounds checking and validity verification to prevent unsafe memory access while maintaining the ability to interact with native libraries

Inventive Principle:
Principle #24Intermediary (Mediator)

2Reliability

If the Java runtime environment performs bounds checking on memory access, then unsafe memory access is prevented, but the complexity of the memory access mechanism increases

Engineering Contradiction:
Improvememory access safetyVSAvoidmemory access mechanism complexity
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent segments the memory access mechanism into distinct components: a memory segment view object that manages the memory address, automatic bounds checking logic, and controlled dereference operations. This segmentation organizes the complexity into manageable, reusable components that provide safety without overwhelming the overall system architecture

Inventive Principle:
Principle #1Segmentation

3Adaptability or versatility

If memory addresses are used as sentinel values for information exchange, then communication with legacy native libraries is enabled, but dereferencing these addresses causes unintended behavior

Engineering Contradiction:
Improvecompatibility with legacy native librariesVSAvoidunintended behavior from dereferencing sentinel addresses
Core Design Contradiction:
Adaptability or versatilityVSObject-generated harmful factors

Solution Approach 1:

The patent performs preliminary validation of the memory address within the memory segment view before any dereference operation occurs. The system pre-checks whether the address is a valid sentinel value or points to actual data, and only allows dereferencing when appropriate. This preliminary action prevents unintended behavior from dereferencing sentinel addresses while maintaining compatibility with legacy native libraries that use such addresses for information exchange

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS11543976B2Methods for reducing unsafe memory access when interacting with native libraries
Publication Date: 2023.01.03 ORACLE INT CORP
  • US11543976B2 patent drawing
  • US11543976B2 patent drawing
  • US11543976B2 patent drawing

AI summary

Techniques for reducing unsafe memory access, particularly when interacting with native libraries, are disclosed. The system may receive a memory address. The system may determine that the received memory address is not associated with an existing memory segment. The system selects a particular memory segment, of a plurality of memory segments. The memory segment may have a length of zero and a size corresponding to a size of a native heap. The system may return a reference to the particular memory segment.