Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gensym behavior between 1ef6db1 and bb5c377 #753

Closed
sogaiu opened this issue Aug 6, 2021 · 2 comments
Closed

gensym behavior between 1ef6db1 and bb5c377 #753

sogaiu opened this issue Aug 6, 2021 · 2 comments

Comments

@sogaiu
Copy link
Contributor

sogaiu commented Aug 6, 2021

It looks like since 1ef6db1 , gensym is not behaving like:

/* Generate a unique symbol. This is used in the library function gensym. The
 * symbol will be of the format _XXXXXX, where X is a base64 digit, and
 * prefix is the argument passed. No prefix for speed. */

Example:

Janet 1.17.0-dev-61769c8f linux/x64 - '(doc)' for help
repl:1:> (gensym)

repl:2:> (type (gensym))
:symbol

The return value of (gensym) is not visible on my terminal.

Examined under gdb it looked like the leading byte was 0.

gensym_counter used to be initialized like this: 1ef6db1#diff-25c765d33445b0e34add62c8093ae0f902e5c87ec602c591c71e644e5b858c2aL198

Since the commit above, it looks like janet_vm.gensym_counter is filled with 0 bytes: 1ef6db1#diff-25c765d33445b0e34add62c8093ae0f902e5c87ec602c591c71e644e5b858c2aR46

The following seems to work in light testing here:


/* Initialize the cache (allocate cache memory) */
void janet_symcache_init() {
    janet_vm.cache_capacity = 1024;
    janet_vm.cache = janet_calloc(1, (size_t) janet_vm.cache_capacity * sizeof(const uint8_t *));
    if (NULL == janet_vm.cache) {
        JANET_OUT_OF_MEMORY;
    }
    const uint8_t gensym_counter[8] = {'_', '0', '0', '0', '0', '0', '0', 0};
    memcpy(janet_vm.gensym_counter, gensym_counter, sizeof(gensym_counter));
    janet_vm.cache_count = 0;
    janet_vm.cache_deleted = 0;
}
@sogaiu sogaiu changed the title gensym behavior since 1ef6db16eda21f4b8cbb73682dcd388e36fe1202 gensym behavior since 1ef6db Aug 6, 2021
@saikyun
Copy link
Contributor

saikyun commented Aug 6, 2021

I tried sogaiu's fix, and it works for me. :)

@sogaiu sogaiu changed the title gensym behavior since 1ef6db gensym behavior between 1ef6db1 and 61769c8 Aug 6, 2021
bakpakin added a commit that referenced this issue Aug 6, 2021
@bakpakin bakpakin closed this as completed Aug 6, 2021
@saikyun
Copy link
Contributor

saikyun commented Aug 7, 2021

Thanks!

@sogaiu sogaiu changed the title gensym behavior between 1ef6db1 and 61769c8 gensym behavior between 1ef6db1 and bb5c377 Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants