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

Constant that is an alias of another constant that is an alias of an imported symbol causes race condition #4668

Open
karl-zylinski opened this issue Jan 8, 2025 · 1 comment

Comments

@karl-zylinski
Copy link
Contributor

Context

    Odin:    dev-2025-01:71b0f7e69
    OS:      Windows 10 Professional (version: 22H2), build 19045.5247
    CPU:     Intel(R) Core(TM) i7-6950X CPU @ 3.00GHz
    RAM:     32674 MiB
    Backend: LLVM 18.1.8

Expected Behavior

read_entire_file :: _read_entire_file in one file

and

_read_entire_file :: os.read_entire_file in another file should work.

Current Behavior

Sometimes (race condition) you get:

C:/code/order_bug/a.odin(5:21) Error: Invalid declaration value '_read_entire_file' 
	read_entire_file :: _read_entire_file 
	                    ^~~~~~~~~~~~~~~~^ 

Failure Information (for bugs)

Steps to Reproduce

a.odin

package order_bug

import "core:fmt"

read_entire_file :: _read_entire_file

main :: proc() {
	if data, ok := read_entire_file("file.txt"); ok {
		fmt.println(string(data))
	}
}

b.odin

package order_bug

import "core:os"

_read_entire_file :: os.read_entire_file

Save both into a folder and run:
odin run .

Sometimes you'll get:

C:/code/order_bug/a.odin(5:21) Error: Invalid declaration value '_read_entire_file' 
	read_entire_file :: _read_entire_file 
	                    ^~~~~~~~~~~~~~~~^ 

It's a race condition so you only get it sometimes.

Doing read_entire_file :: os.read_entire_file without the in-between _ version makes it work.

It only happens when I use an imported symbol in _read_entire_file :: os.read_entire_file... If I do read_entire_file :: 5 then it works OK (given that I also change the code in main).

@karl-zylinski
Copy link
Contributor Author

Might be related to #4239

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

1 participant