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

In get_system_shard_key() BoundsError: attempt to access 2-element Vector{String} at index [] #450

Closed
emmt opened this issue Oct 19, 2023 · 7 comments

Comments

@emmt
Copy link

emmt commented Oct 19, 2023

With Julia-1.6.7 and Clang-0.14.1 on Linux Ubuntu 23.04, calling get_default_args() gives the following error :

ERROR: BoundsError: attempt to access 2-element Vector{String} at index []
Stacktrace:
  [1] throw_boundserror(A::Vector{String}, I::Tuple{})
    @ Base ./abstractarray.jl:651
  [2] checkbounds
    @ ./abstractarray.jl:616 [inlined]
  [3] _getindex
    @ ./abstractarray.jl:1196 [inlined]
  [4] getindex
    @ ./abstractarray.jl:1170 [inlined]
  [5] get_system_shard_key(triple::String)
    @ Clang.JLLEnvs ~/.julia/packages/Clang/x6vao/src/shards/JLLEnvs.jl:96
  [6] get_environment_info(triple::String, version::VersionNumber)
    @ Clang.JLLEnvs ~/.julia/packages/Clang/x6vao/src/shards/JLLEnvs.jl:102
  [7] get_system_dirs(triple::String, version::VersionNumber)
    @ Clang.JLLEnvs ~/.julia/packages/Clang/x6vao/src/shards/JLLEnvs.jl:114
  [8] get_system_dirs
    @ ~/.julia/packages/Clang/x6vao/src/shards/JLLEnvs.jl:113 [inlined]
  [9] get_default_args(triple::String) (repeats 2 times)
    @ Clang.Generators ~/.julia/packages/Clang/x6vao/src/generator/context.jl:233
 [10] top-level scope
    @ REPL[14]:1

This is due to variable platform_keys in get_system_shard_key() having more than one element and thus platform_keys[] fails with the above error.

The code of get_system_shard_key() has not changed since Clang-0.14.0 (if I am correctly using git blame). I would suggest to fix this by using expression:

return first(platform_keys)

instead of:

return platform_keys[]

in function get_system_shard_key in file src/shards/JLLEnvs.jl. But I am not sure that this would be correct...

It would be nice to retroproagate the fix to older versions of Clang, at least to the 0.14 branch, to be able to use Clang with Julia-1.6.

@Gnimuc
Copy link
Member

Gnimuc commented Oct 20, 2023

does Clang.jl work properly after fixing the issue?

@Gnimuc
Copy link
Member

Gnimuc commented Oct 20, 2023

I'm a bit worried about the compatibility margin between Julia-1.6 and Ygg-JLL-BB2.

@emmt
Copy link
Author

emmt commented Oct 20, 2023

I did not tried the proposed fix because I was not sure of the purpose of get_system_shard_key. In particular, if it is supposed to fail when platform_keys is not an array with exactly one element, then my fix breaks this assumption. The other concern is: I choose the first element of platform_keys because I assumed that it is as good as any other. But is this true?

@Gnimuc
Copy link
Member

Gnimuc commented Oct 22, 2023

It's the system shard key in the toml file: https://github.com/JuliaInterop/Clang.jl/blob/master/Artifacts.toml

I think this fix is ok: first(platform_keys)

but I'm not sure whether there are other compatibility issues. (your system Linux Ubuntu 23.04 is new but the gcc shipped with the system is probably missing in Ygg)

@emmt
Copy link
Author

emmt commented Oct 23, 2023

I have just tried the proposed fix. This works for Julia 1.6 with Clang 0.14.1

I can make a PR but I do not know how to propagate to other versions.

emmt added a commit to emmt/Clang.jl that referenced this issue Oct 24, 2023
@emmt emmt mentioned this issue Oct 24, 2023
@emmt
Copy link
Author

emmt commented Oct 24, 2023

PR #451 attempts to fix this.

Gnimuc pushed a commit that referenced this issue Nov 5, 2023
@Gnimuc
Copy link
Member

Gnimuc commented Apr 8, 2024

I just noticed the root cause of the problem is that the Artifacts.toml file is somehow broken, but the logic used in get_system_shard_key assumes there should be only one matched entry...

@Gnimuc Gnimuc closed this as completed Apr 8, 2024
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

2 participants