Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

When pushing context inside a #c_call callback function, it might cause a corrupt execution of the callback.
This issue appears when compiling with the X64 backend. The LLVM backend seems not affected.

Tested with following configurations:

System1

  • Jai: 0.2.029, 0.2.030
  • Clang: 22.1.6
  • OS: Linux, Arch, Kernel 7.0.10

System2

  • Jai: 0.2.027
  • Clang: 20.1.8
  • OS: Linux, Arch, Kernel 6.16.5

Code

This is the callback which lives in main.jai:

visit_entries :: (root: *u8, entry: *void, user_data: *void) -> s32 #c_call {
    push_context { log("Yoooo"); }
    return 0;
}

In it's current shape, it executes correctly. Printing "Yoooo" three times.

Adding a new variable into the mix:

visit_entries :: (root: *u8, entry: *void, user_data: *void) -> s32 #c_call {
    coconut_png := 420691337;

    push_context { log("Yoooo"); }
    return 0;
}

Now it prints "Yoooo" several times and terminates with a segfault. You could also replace the integer with an boolean.

Repro

Run it with:

jai build.jai - run

This generates bindings to a test C lib I included, builds the project with the X64 backend and executes the program.

If you want to test it with the LLVM backend, append "release" to the args:

jai build.jai - run release

Further Context

Initially the issue appeared when working with libgit2.
The git_tree_walk function takes a callback and at some point it only returned one node, instead of 18.
The callback function was way bigger and certain combinations of variables and function calls caused some broken behavior.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages