Skip to content

Commit 5495b8d

Browse files
authored
Fix GCExt test (#47699)
* Add test/gcext to out-of-tree * Disable gcext test that uses jl_gc_internal_obj_base_ptr
1 parent 60668c5 commit 5495b8d

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ all: debug release
2828
# sort is used to remove potential duplicates
2929
DIRS := $(sort $(build_bindir) $(build_depsbindir) $(build_libdir) $(build_private_libdir) $(build_libexecdir) $(build_includedir) $(build_includedir)/julia $(build_sysconfdir)/julia $(build_datarootdir)/julia $(build_datarootdir)/julia/stdlib $(build_man1dir))
3030
ifneq ($(BUILDROOT),$(JULIAHOME))
31-
BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src src/flisp src/support src/clangsa cli doc deps stdlib test test/clangsa test/embedding test/llvmpasses)
31+
BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src src/flisp src/support src/clangsa cli doc deps stdlib test test/clangsa test/embedding test/gcext test/llvmpasses)
3232
BUILDDIRMAKE := $(addsuffix /Makefile,$(BUILDDIRS)) $(BUILDROOT)/sysimage.mk
3333
DIRS += $(BUILDDIRS)
3434
$(BUILDDIRMAKE): | $(BUILDDIRS)

src/julia_gcext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ JL_DLLEXPORT int jl_gc_conservative_gc_support_enabled(void);
120120
// external allocations may not all be valid objects and that for those,
121121
// the user *must* validate that they have a proper type, i.e. that
122122
// jl_typeof(obj) is an actual type object.
123+
//
124+
// NOTE: Only valid to call from within a GC context.
123125
JL_DLLEXPORT jl_value_t *jl_gc_internal_obj_base_ptr(void *p);
124126

125127
// Return a non-null pointer to the start of the stack area if the task

test/gcext/LocalTest.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ function set_aux_root(n :: Int, x :: String)
5454
return ccall(:set_aux_root, Nothing, (UInt, String), n, x)
5555
end
5656

57-
function internal_obj_scan(p :: Any)
58-
if ccall(:internal_obj_scan, Cint, (Any,), p) == 0
59-
global internal_obj_scan_failures += 1
60-
end
61-
end
57+
# function internal_obj_scan(p :: Any)
58+
# if ccall(:internal_obj_scan, Cint, (Any,), p) == 0
59+
# global internal_obj_scan_failures += 1
60+
# end
61+
# end
6262

63-
global internal_obj_scan_failures = 0
63+
# global internal_obj_scan_failures = 0
6464

6565
for i in 0:1000
6666
set_aux_root(i, string(i))
@@ -70,12 +70,12 @@ function test()
7070
local stack = make()
7171
for i in 1:100000
7272
push(stack, string(i, base=2))
73-
internal_obj_scan(top(stack))
73+
# internal_obj_scan(top(stack))
7474
end
7575
for i in 1:1000
7676
local stack2 = make()
77-
internal_obj_scan(stack2)
78-
internal_obj_scan(blob(stack2))
77+
# internal_obj_scan(stack2)
78+
# internal_obj_scan(blob(stack2))
7979
while !empty(stack)
8080
push(stack2, pop(stack))
8181
end
@@ -98,5 +98,5 @@ end
9898
print(gc_counter_full(), " full collections.\n")
9999
print(gc_counter_inc(), " partial collections.\n")
100100
print(num_obj_sweeps(), " object sweeps.\n")
101-
print(internal_obj_scan_failures, " internal object scan failures.\n")
101+
# print(internal_obj_scan_failures, " internal object scan failures.\n")
102102
print(corrupted_roots, " corrupted auxiliary roots.\n")

test/gcext/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $(BIN)/gcext-debug$(EXE): $(SRCDIR)/gcext.c
4141
ifneq ($(abspath $(BIN)),$(abspath $(SRCDIR)))
4242
# for demonstration purposes, our demo code is also installed
4343
# in $BIN, although this would likely not be typical
44-
$(BIN)/LocalModule.jl: $(SRCDIR)/LocalModule.jl
44+
$(BIN)/LocalTest.jl: $(SRCDIR)/LocalTest.jl
4545
cp $< $@
4646
endif
4747

test/gcext/gcext-test.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ end
3131
errlines = fetch(err_task)
3232
lines = fetch(out_task)
3333
@test length(errlines) == 0
34-
@test length(lines) == 6
34+
# @test length(lines) == 6
35+
@test length(lines) == 5
3536
@test checknum(lines[2], r"([0-9]+) full collections", n -> n >= 10)
3637
@test checknum(lines[3], r"([0-9]+) partial collections", n -> n > 0)
3738
@test checknum(lines[4], r"([0-9]+) object sweeps", n -> n > 0)
38-
@test checknum(lines[5], r"([0-9]+) internal object scan failures",
39-
n -> n == 0)
40-
@test checknum(lines[6], r"([0-9]+) corrupted auxiliary roots",
39+
# @test checknum(lines[5], r"([0-9]+) internal object scan failures",
40+
# n -> n == 0)
41+
# @test checknum(lines[6], r"([0-9]+) corrupted auxiliary roots",
42+
# n -> n == 0)
43+
@test checknum(lines[5], r"([0-9]+) corrupted auxiliary roots",
4144
n -> n == 0)
4245
end

test/gcext/gcext.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ static size_t gc_alloc_size(jl_value_t *val)
307307

308308
int internal_obj_scan(jl_value_t *val)
309309
{
310+
// FIXME: `jl_gc_internal_obj_base_ptr` is not allowed to be called from outside GC
310311
if (jl_gc_internal_obj_base_ptr(val) == val) {
311312
size_t size = gc_alloc_size(val);
312313
char *addr = (char *)val;

0 commit comments

Comments
 (0)