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

ARGS constant doesn't get set correctly anymore #68

Closed
StefanKarpinski opened this issue Jun 21, 2011 · 7 comments
Closed

ARGS constant doesn't get set correctly anymore #68

StefanKarpinski opened this issue Jun 21, 2011 · 7 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@StefanKarpinski
Copy link
Sponsor Member

$ julia -e 'println(ARGS)'
Array(Any,(0,))
$ julia -e 'println(ARGS)' foo bar
Array(Any,(0,))
@ghost ghost assigned StefanKarpinski Jun 21, 2011
@StefanKarpinski
Copy link
Sponsor Member Author

@JeffBezanson: I can't figure out why this doesn't work. The code is here and appears in the debugger to be doing the right things:

jl_array_t *args = jl_alloc_cell_1d(argc);
jl_set_const(jl_system_module, jl_symbol("ARGS"), (jl_value_t*)args);
int i;
for (i=0; i < argc; i++) {
    jl_arrayset(args, i, (jl_value_t*)jl_cstr_to_string(argv[i]));
}

Stepping through it, everything looks fine, but then when I try to access ARGS as above from julia, I get a zero-element cell array instead of the properly initialized ARGS. Am I doing something wrong here? Did the usage of one of these functions change? Or is this a weird interaction with the snapshot restoration process?

@StefanKarpinski
Copy link
Sponsor Member Author

Right after that, setting the JULIA_HOME constant works:

jl_set_const(jl_system_module, jl_symbol("JULIA_HOME"),
             jl_cstr_to_string(julia_home));

So that set of functions still appears to be working as expected.

@JeffBezanson
Copy link
Sponsor Member

D'oh, it must be because the system image saves the value, and it's a constant so it won't let you overwrite the value. I guess we should allow overwriting constants from the C API.

@StefanKarpinski
Copy link
Sponsor Member Author

How does this even get set in the image? Ideally, the constant should get created only after loading the image. Likewise, JULIA_HOME should get reset each time. An alternative would be to make these not be constants at all. Also, I added JULIA_HOME before we has access to the EnvHash singleton so maybe that should just be gone.

@JeffBezanson
Copy link
Sponsor Member

Because it gets set every time julia starts, and the system image saves the entire state. So the system image contains the values as they were when the image was saved. They don't have to be constants, you can change that if you want.
JULIA_HOME is not always an environment variable. It's set using the proc filesystem to find where julia actually is. I don't see the advantage of typing ENV["JULIA_HOME"] instead of just the variable name.

@StefanKarpinski
Copy link
Sponsor Member Author

No, I guess that's fair. And sometimes ENV["JULIA_HOME"] and JULIA_HOME won't match. If they're not constants would that solve the issue?

@JeffBezanson
Copy link
Sponsor Member

Yeah, just use jl_set_global instead of jl_set_const

StefanKarpinski added a commit that referenced this issue Feb 8, 2018
bin/version.sh: check code for generating version numbers into bin
StefanKarpinski added a commit that referenced this issue Feb 8, 2018
cmcaine pushed a commit to cmcaine/julia that referenced this issue Sep 24, 2020
* Remove leading 'x' from repository name

The leading 'x' is kind of arbitrary. Especially now that we can set
topics on the repositories, we don't need a pattern to distinguish what
is a track or not.

The repository itself has already been renamed. GitHub redirects from
the old name to the new name, so we do not have to rush to fix links to
the old repository name, though we should update them for the sake of
clarity.

* Clean up references to old repository name [skip ci]

We renamed the language track repositories, removing the leading 'x',
as this is cleaner and more understandable.

This does minor cleanup to fix references to the old name.
Keno pushed a commit that referenced this issue Oct 9, 2023
Avoid illegal instruction crash by circumventing ccall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants