ivmai / bdwgc

The Boehm-Demers-Weiser conservative C/C++ Garbage Collector (bdwgc, also known as bdw-gc, boehm-gc, libgc)
https://www.hboehm.info/gc/
Other
3.01k stars 406 forks source link

cordtest hang on Windows if shared build by Zig using msvc #640

Open ivmai opened 6 months ago

ivmai commented 6 months ago

Source: master (2eaa40c49) Build: https://github.com/ivmai/bdwgc/actions/runs/8928784437/job/24525078409 Zig version: 0.12.0 Command: zig build -Dtarget=native-native-msvc -DBUILD_SHARED_LIBS=true -Ddisable_handle_fork=false -Denable_cplusplus=false -Denable_gc_assertions=true -Denable_gc_debug=false -Denable_large_config=false -Denable_munmap=true -Denable_parallel_mark=false -Denable_redirect_malloc=false -Denable_rwlock=false -Denable_thread_local_alloc=false -Denable_threads=false -Denable_werror -Dbuild_cord=true "-DCFLAGS_EXTRA=-DGC_PRINT_VERBOSE_STATS -DCONSOLE_LOG" test Output (cordtest):

Got 65536 bytes from OS
Got 6[5](https://github.com/ivmai/bdwgc/actions/runs/8928784437/job/24525078409#step:4:6)536 bytes from OS
Got 6553[6](https://github.com/ivmai/bdwgc/actions/runs/8928784437/job/24525078409#step:4:7) bytes from OS
In-use heap: 0% (0 KiB pointers + 0 KiB other)
Got 65536 bytes from OS
Grow heap to 64 KiB after 0 bytes allocated
Grew heap sections array to 32 elements
Initiating full world-stop collection!
0 bytes in heap blacklisted for interior pointers
Found new system malloc AllocationBase at 00000291F[7](https://github.com/ivmai/bdwgc/actions/runs/8928784437/job/24525078409#step:4:8)900000
--> Marking for collection #1 after 0 allocated bytes
World-stopped marking took 16 ms 0 ns (16 ms in average)
Bytes recovered before sweep - f.l. count = 0
GC #1 freed 0 bytes, heap 64 KiB (+ 0 KiB unmapped + 362 KiB internal)
In-use heap: 0% (0 KiB pointers + 0 KiB other)
0 finalization entries; 0/0 short/long disappearing links alive
0 finalization-ready objects; 0/0 short/long links cleared
Finalize and initiate sweep took 0 ms 0 ns + 0 ms 0 ns
Complete collection took [16](https://github.com/ivmai/bdwgc/actions/runs/8928784437/job/24525078409#step:4:17) ms 0 ns
Initializing mprotect virtual dirty bit implementation
Using GetWriteWatch()
Adding block map for size of 1 granules (16 bytes)
Adding block map for size of 2 granules (32 bytes)
ivmai commented 6 months ago

I tried to reproduce it locally, but failed to setup build environment with Zig using MSVC (I don't have such issue with e.g. cmake): <path_to_zig>\zig.exe build -Dtarget=native-native-msvc produces output (without enough details):

Build Summary: 1/6 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
+- install gc transitive failure
|  +- zig build-lib gc Debug native-native-msvc failure
+- install cord transitive failure
   +- zig build-lib cord Debug native-native-msvc transitive failure
      +- zig build-lib gc Debug native-native-msvc (reused)
error: the following build command failed with exit code 1:
...\zig-cache\o\e6349bcf924ab91855bda5bf668ba4bf\build.exe
ivmai commented 6 months ago

@kassane If possible, please help investigating this issue.

kassane commented 6 months ago

commit: https://github.com/ivmai/bdwgc/commit/b1fe06200d716cd63d3ec321654fb4d03d610240 MinGW build: :ok: MSVC build: :x:

preview-error ![image](https://github.com/ivmai/bdwgc/assets/6756180/80cd25de-44e0-4420-9937-20575f6e4231)
ivmai commented 6 months ago

commit: b1fe062 MinGW build: 🆗 MSVC build: ❌

preview-error

Please give me more details: which build configuration? Do you have ideas why process.h is not found?

kassane commented 6 months ago

Please give me more details: which build configuration? Do you have ideas why process.h is not found?

Sorry! It was a winSDK dependency failure. [ignore]

After using windbg, I realized that it always marked the same point, so I tested each test function separately.

The issue occurs on test_extras - exactly Cord_from_file(). image

kassane commented 6 months ago

ABORT(msg) no emit any error about...

**msvc-sharedlib** ![image](https://github.com/ivmai/bdwgc/assets/6756180/366036ae-e74b-44a7-872b-3167a495535f)
kassane commented 6 months ago

I tried to reproduce it locally, but failed to setup build environment with Zig using MSVC (I don't have such issue with e.g. cmake):

CMake - msvc libs - more complete

Zig - msvc libs