Skip to content

Conversation

@wesjenkins
Copy link
Contributor

Fixes issue #45126, where Base.libllvm_path doesn't support non-ASCII characters. jl_get_libllvm_impl has been changed from using GetModuleFileNameA to using GetModuleFileNameW, along with WideCharToMultiByte to turn it into UTF-8.

src/codegen.cpp Outdated
DWORD n16 = GetModuleFileNameW(mod, path16, MAX_PATH);
if (n16 <= 0)
return jl_nothing;
char path8[MAX_PATH * 2];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why *2, not *3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can bump it up to 3 to be safe

src/codegen.cpp Outdated
if (n16 <= 0)
return jl_nothing;
char path8[MAX_PATH * 2];
if (!WideCharToMultiByte(CP_UTF8, 0, path16, n16, path8, MAX_PATH * 2, NULL, NULL))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need +1 to add a trailing null byte here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right, I need to fix the null, I'll do that.

@giordano
Copy link
Member

Is this somehow related to #33486?

@wesjenkins
Copy link
Contributor Author

wesjenkins commented Apr 30, 2022

Is this somehow related to #33486?

I'm not sure, but I doubt it. This is a very local issue just inside jl_get_libllvm. But there do seem to be a few more non-ASCII username bugs floating around, so I could be wrong.

@zpcpi
Copy link

zpcpi commented Feb 11, 2023

I still have similar problems
#48648

@vtjnash
Copy link
Member

vtjnash commented Feb 12, 2023

Sorry we forgot to merge this!

@vtjnash vtjnash added this to the 1.9 milestone Feb 12, 2023
@KristofferC KristofferC added the backport 1.9 Change should be backported to release-1.9 label Feb 14, 2023
@KristofferC KristofferC merged commit 6976bac into JuliaLang:master Feb 14, 2023
@vtjnash
Copy link
Member

vtjnash commented Feb 14, 2023

@KristofferC that is a rather awkward commit message, which seems to mention several changes that you squashed out of the final version

KristofferC pushed a commit that referenced this pull request Feb 20, 2023
…acters in path on Windows (#45126) (#45127)

* Fix jl_get_libllvm_impl to support non-ASCII characters

* Fix jl_get_libllvm_impl to support non-ASCII characters, fix whitespace

* Fix jl_get_libllvm_impl to support non-ASCII characters, fix null and buffer

(cherry picked from commit 6976bac)
@KristofferC KristofferC mentioned this pull request Feb 20, 2023
50 tasks
@KristofferC KristofferC removed the backport 1.9 Change should be backported to release-1.9 label Mar 6, 2023
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

Successfully merging this pull request may close these issues.

Base.libllvm_path and jl_get_libllvm don't support non-ASCII characters in path on Windows

6 participants