Skip to content

Commit a93d1eb

Browse files
committed
fix issues from #8745 (comments), incl. fixing #12208
1 parent 198fd16 commit a93d1eb

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

doc/manual/modules.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ not a standalone interpreter that also generates compiled code.
340340

341341
Other known potential failure scenarios include:
342342

343-
1. Global counters (for example, for uniquely identify objects)
343+
1. Global counters (for example, for attempting to unique identifying objects)
344344
Consider the following code snippet::
345345

346346
type UniquedById
@@ -355,6 +355,9 @@ Other known potential failure scenarios include:
355355
All subsequent usages of this incrementally compiled module
356356
will start from that same counter value.
357357

358+
Note that ``object_id`` (which works by hashing the memory pointer)
359+
has similar issues (see notes on Dict usage below).
360+
358361
One alternative is to store both ``current_module()`` and the current ``counter`` value,
359362
however, it may be better to redesign the code to not depend on this global state.
360363

@@ -384,7 +387,7 @@ to help the user avoid other wrong-behavior situations:
384387

385388
2. ``global const`` statements from local scope after ``__init__()`` has been started (see issue #12010 for plans to add an error for this)
386389

387-
3. Replacing a module (or calling ``workspace()`` is a runtime error while doing an incremental compile.
390+
3. Replacing a module (or calling ``workspace()``) is a runtime error while doing an incremental compile.
388391

389392
A few other points to be aware of:
390393

@@ -399,5 +402,5 @@ A few other points to be aware of:
399402
However, when possible, it can be good practice to copy resources
400403
into the module at compile-time so they won't need to be found at runtime.
401404

402-
4. WeakRef objects and finalizers are not captured by currently handled by the serializer
405+
4. WeakRef objects and finalizers are not currently handled properly by the serializer
403406
(this will be fixed in an upcoming release).

doc/stdlib/base.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Getting Around
8686

8787
When searching for files, ``require`` first looks in the current working directory, then looks for package code under ``Pkg.dir()``, then tries paths in the global array ``LOAD_PATH``.
8888

89-
.. function:: compile(module::String)
89+
.. function:: compile(module::Symbol)
9090

9191
Creates a precompiled cache file for module (see help for ``require``) and all of its dependencies. This can be used to reduce package load times. Cache files are stored in LOAD_CACHE_PATH[1], which defaults to `~/.julia/lib/VERSION`. See the manual section `Module initialization and precompilation` (under `Modules`) for important notes.
9292

src/dump.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ static void jl_serialize_globalvals(ios_t *s)
288288
size_t i, len = backref_table.size;
289289
void **p = backref_table.table;
290290
for(i=0; i < len; i+=2) {
291-
void *offs = p[i+1];
291+
char *offs = (char*)p[i+1];
292292
if (offs != HT_NOTFOUND) {
293-
uintptr_t pos = offs - HT_NOTFOUND - 1;
293+
uintptr_t pos = offs - (char*)HT_NOTFOUND - 1;
294294
int32_t gv = jl_get_llvm_gv((jl_value_t*)p[i]);
295295
if (gv != 0) {
296296
write_int32(s, pos);
@@ -604,8 +604,8 @@ static void jl_serialize_value_(ios_t *s, jl_value_t *v)
604604
else {
605605
bp = ptrhash_bp(&backref_table, v);
606606
if (*bp != HT_NOTFOUND) {
607-
uintptr_t pos = *bp - HT_NOTFOUND - 1;
608-
if ((uptrint_t)*bp < 65536) {
607+
uintptr_t pos = (char*)*bp - (char*)HT_NOTFOUND - 1;
608+
if (pos < 65536) {
609609
write_uint8(s, ShortBackRef_tag);
610610
write_uint16(s, pos);
611611
}
@@ -631,7 +631,7 @@ static void jl_serialize_value_(ios_t *s, jl_value_t *v)
631631
}
632632
if (mode == MODE_MODULE || mode == MODE_MODULE_POSTWORK)
633633
pos <<= 1;
634-
ptrhash_put(&backref_table, v, HT_NOTFOUND + pos + 1);
634+
ptrhash_put(&backref_table, v, (char*)HT_NOTFOUND + pos + 1);
635635
}
636636

637637
size_t i;
@@ -1896,7 +1896,7 @@ DLLEXPORT int jl_save_incremental(const char *fname, jl_array_t *worklist)
18961896
JL_SIGATOMIC_BEGIN();
18971897
arraylist_new(&reinit_list, 0);
18981898
htable_new(&backref_table, 5000);
1899-
ptrhash_put(&backref_table, jl_main_module, HT_NOTFOUND + 1);
1899+
ptrhash_put(&backref_table, jl_main_module, (char*)HT_NOTFOUND + 1);
19001900
backref_table_numel = 1;
19011901
jl_idtable_type = jl_base_module ? jl_get_global(jl_base_module, jl_symbol("ObjectIdDict")) : NULL;
19021902

test/runtests.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
include("choosetests.jl")
44
tests, net_on = choosetests(ARGS)
5-
n = 1
6-
if net_on
7-
n = min(8, CPU_CORES, length(tests))
8-
n > 1 && addprocs(n; exeflags=`--check-bounds=yes --depwarn=error`)
9-
blas_set_num_threads(1)
10-
end
5+
let n = 1
6+
if net_on
7+
n = min(8, CPU_CORES, length(tests))
8+
n > 1 && addprocs(n; exeflags=`--check-bounds=yes --depwarn=error`)
9+
blas_set_num_threads(1)
10+
end
1111

12-
@everywhere include("testdefs.jl")
12+
@everywhere include("testdefs.jl")
1313

14-
reduce(propagate_errors, nothing, pmap(test->runtests(test), tests; err_retry=false, err_stop=true))
14+
reduce(propagate_errors, nothing, pmap(test->runtests(test), tests; err_retry=false, err_stop=true))
1515

16-
@unix_only n > 1 && rmprocs(workers(), waitfor=5.0)
17-
println(" \033[32;1mSUCCESS\033[0m")
16+
@unix_only n > 1 && rmprocs(workers(), waitfor=5.0)
17+
println(" \033[32;1mSUCCESS\033[0m")
18+
end

0 commit comments

Comments
 (0)