Skip to content

Finaliser call regression after updating to boehmgc 8.2 #334

Open

Description

@tobil4sk

After updating boehmgc to 8.2 in #307. it appears there is a regression with some finalisers not being called on Windows 64-bit. This was observed in the hxcpp test suite (which compares ndll behaviour across hxcpp and neko)

https://github.com/HaxeFoundation/hxcpp/blob/199b756483f40a622fddf789ef450f5e379cab77/test/cffi/src/TestCffi.hx#L171

https://github.com/HaxeFoundation/hxcpp/actions/runs/35778010459/job/106916042227#step:11:23

src/TestPrime.hx:51: null ?null/4

assertations: 266
successes: 264
errors: 0
failures: 1
warnings: 1
execution time: 0.001

results: SOME TESTS FAILURES (success: false)
TestCffi
  testCffi: FAILURE .........................................W........................................................................................................................................................................................................F
    1 != 2
    line: 171, expected 2 but it is 1
x : 11.000000
null fields
String : HxString (8)

I've been trying to reduce it to a minimal neko program, but currently running into some issues. Might have to revert the upgrade for now.

Activity

  1. tobil4sk commented on Sep 29, 2026

    @tobil4sk
    MemberAuthor

    This minimal project can reproduce the issue, though not consistently

    test.neko

    var runGc = $loader.loadprim("std@run_gc",1);
    var allocAbstract = $loader.loadprim("test@allocAbstract",0);
    {
    	var tmp = allocAbstract();
    	var tmp = allocAbstract();
    }
    runGc(true);

    test.c

    #include <neko.h>
    
    DEFINE_KIND(my_kind);
    
    void freeMyKind(value inAbstract)
    {
    	puts("freeMyKind");
    }
    
    value allocAbstract()
    {
    	puts("allocAbstract");
    
    	value abs = alloc_abstract(my_kind, (void *)11);
    	val_gc(abs, freeMyKind);
    	return abs;
    }
    DEFINE_PRIM(allocAbstract, 0);

    CMakeLists.txt

    cmake_minimum_required(VERSION 3.10)
    
    project(Test C)
    
    add_library(test.ndll MODULE test.c)
    
    find_library(NEKO_LIBRARIES neko HINTS C:\\HaxeToolkit\\neko)
    find_path(NEKO_INCLUDE_DIRS neko.h HINTS C:\\HaxeToolkit\\neko\\include)
    
    target_link_libraries(test.ndll ${NEKO_LIBRARIES})
    target_include_directories(test.ndll PRIVATE ${NEKO_INCLUDE_DIRS})
    
    set_target_properties(test.ndll
    	PROPERTIES
    	PREFIX ""
    	OUTPUT_NAME test
    	SUFFIX .ndll
    )
    
    install(
    	TARGETS test.ndll
    	DESTINATION ${CMAKE_SOURCE_DIR}
    )
    cmake -B build
    cmake --build build --target install
    nekoc test.neko
    neko test.n
  2. tobil4sk commented on Oct 9, 2026

    @tobil4sk
    MemberAuthor

    One theory is that the register containing the abstract used to be overwritten by bdwgc code in the runGc call, but now some argument or variable got removed and register containing the abstract pointer remains intact, so the object is treated as live.

  3. added a commit that references this issue on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions