infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
851_lifecycle_regression.c File Reference

Regression tests for specific memory lifecycle and ownership bugs. More...

#include "common/double_tap.h"
#include <infix/infix.h>
#include <string.h>
Include dependency graph for 851_lifecycle_regression.c:

Macros

#define DBLTAP_IMPLEMENTATION
 

Functions

void dummy_func ()
 
 subtest ("Use-after-free of resolved named pointee type")
 
 subtest ("Garbage output from infix_type_print on copied named type")
 
 subtest ("Lifecycle with direct and nested named types")
 
 subtest ("Lifecycle with recursive named types")
 
 subtest ("Expanded infix_type_print validation for named types")
 
 subtest ("Introspection of resolved named types")
 

Variables

 TEST
 

Detailed Description

Regression tests for specific memory lifecycle and ownership bugs.

This test file targets specific, subtle bugs related to the memory lifecycle of infix_type objects, particularly when they are copied between different memory arenas during the "Parse -> Copy -> Resolve -> Layout" pipeline.

The tests verify:

  1. Use-After-Free of Pointee Types: Ensures that when a signature like *@Point is parsed, the Point type object (resolved from the registry) remains valid and is not prematurely freed after the temporary parser arena is destroyed.
  2. Correct Printing of Copied Named Types: Verifies that infix_type_print can correctly serialize a type graph that has been deep-copied into a trampoline's private arena, ensuring that pointers to type names remain valid after the copy.
  3. Handling of Recursive Types: Confirms that the deep-copy mechanism correctly handles recursive type definitions (like a linked list node) without causing a stack overflow from infinite recursion, and that the resulting copied graph maintains its correct recursive structure.
  4. Semantic Name Preservation: Validates that the new name field is correctly populated and preserved through the full parse/copy/resolve pipeline for all named types, including aliases.

Macro Definition Documentation

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

Function Documentation

◆ dummy_func()

void dummy_func ( )

◆ subtest() [1/6]

subtest ( "Expanded infix_type_print validation for named types"  )

◆ subtest() [2/6]

subtest ( "Garbage output from infix_type_print on copied named type"  )

◆ subtest() [3/6]

subtest ( "Introspection of resolved named types"  )

◆ subtest() [4/6]

subtest ( "Lifecycle with direct and nested named types"  )

◆ subtest() [5/6]

subtest ( "Lifecycle with recursive named types"  )

◆ subtest() [6/6]

subtest ( "Use-after-free of resolved named pointee type"  )

Variable Documentation

◆ TEST

TEST
Initial value:
{
plan(6)
#define plan(count)
Definition double_tap.h:154