Skip to content

Thread Safety Issues in Random Decision Making and Decision History Tracking #1222

@guptapratykshh

Description

@guptapratykshh

Description:

SQLancer's current implementation uses ThreadLocal for random number generation, which creates significant limitations for tracking decisions across threads and implementing feedback-guided fuzzing. The lack of proper synchronization mechanisms for shared decision history prevents effective multi-threaded test generation.

Current Implementation Issues:

  1. Thread Isolation Problem:
private static final ThreadLocal<Random> THREAD_RANDOM = new ThreadLocal<>();
  • Each thread has its own isolated Random instance
  • No way to share or track decisions across threads
  • Decisions made in one thread are invisible to others
  1. Static Method Usage:
public static boolean getBoolean() {
    return getThreadRandom().get().nextBoolean();
}
  • Static methods make it impossible to maintain thread-specific state
  • No way to track which thread made which decisions
  • Cannot implement thread-aware decision history
  1. Unsynchronized Caching:
private final List<Long> cachedLongs = new ArrayList<>();
private final List<Integer> cachedIntegers = new ArrayList<>();
  • Cache lists are not thread-safe
  • Potential race conditions in cache access
  • No synchronization for shared resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions