Skip to content

load_library() panics on errors when err=0 #47343

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

Merged
merged 1 commit into from
Oct 28, 2022

Conversation

apaz-cli
Copy link
Member

load_library with err=0 now panics on errors, provided that the file is openable. It used to never panic on errors, leading to confusion between when cases the libjuliacodegen library had been intentionally removed and when it tried but failed to load.

Fixes #47027

@vtjnash vtjnash added the needs tests Unit tests are required for this change label Oct 27, 2022
@apaz-cli apaz-cli force-pushed the ap/load-codegen branch 2 times, most recently from a4cadda to 98ddb7a Compare October 27, 2022 15:26
@apaz-cli
Copy link
Member Author

Amended for posix, windows was also wrong. I misread the docs initially.

@apaz-cli apaz-cli force-pushed the ap/load-codegen branch 3 times, most recently from a0098b8 to 1cc5003 Compare October 27, 2022 22:56
load_library with `err=0` now panics on errors, provided that the
file exists. It used to never panic on errors, leading to
confusion between when cases the libjuliacodegen library had been
intentionally removed and when it tried but failed to load.

Fixes JuliaLang#47027
@apaz-cli
Copy link
Member Author

Removed extra whitespace that I accidentally added. Added a test, and CI is passing.

@vtjnash vtjnash removed the needs tests Unit tests are required for this change label Oct 28, 2022
Copy link
Member

@giordano giordano left a comment

Choose a reason for hiding this comment

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

$ julia-1.8.2/bin/julia -q

SYSTEM: caught exception of type ^C^C^C^C^C^C^CWARNING: Force throwing a SIGINT
fatal: error thrown and no exception handler available.
InterruptException()
$ julia-57f9db2279/bin/julia -q
ERROR: Unable to load dependent library /home/dc-gior1/tmp/julia-57f9db2279/bin/../lib/julia/libjulia-codegen.so.1
Message:/usr/local/software/master/gcc/8/lib64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /home/dc-gior1/tmp/julia-57f9db2279/bin/../lib/julia/libjulia-codegen.so.1)

Much better error, yay!

@gbaraldi
Copy link
Member

@giordano maybe this can show what's going on with windows on gcc12?

@giordano
Copy link
Member

I was thinking (and hoping) the same!

@vtjnash
Copy link
Member

vtjnash commented Oct 28, 2022

That was the goal

@DilumAluthge
Copy link
Member

This PR broke the x86_64-w64-mingw32 tests.

@staticfloat
Copy link
Member

It looks to me like we might be missing a UTF16 -> UTF8 conversion somewhere.

return NULL;
#undef PATH_EXISTS
jl_loader_print_stderr3("ERROR: Unable to load dependent library ", path, "\n");
Copy link
Member

@giordano giordano Oct 29, 2022

Choose a reason for hiding this comment

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

Should use wpath on Windows?

Edit: nevermind, my understanding is that we want to print the utf8 string and wpath is the utf16 one. So path somehow is utf16?

Copy link
Member Author

Choose a reason for hiding this comment

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

It should be utf8. The function expects it to be utf8. That it isn't is very odd, and this PR made no changes that would break that.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but the tests introduced here triggered the error, tests were already failing in this PR, but the fact that Windows tests are allowed to fail means that the failure was overlooked

@inkydragon
Copy link
Member

inkydragon commented Oct 30, 2022

jl_loader_print_stderr3
-> jl_loader_print_stderr
-> fputs
-> loader_fputs
-> utf8_to_wchar + fwrite

int loader_fputs(const char *str, FILE *out) {
wchar_t wstr[1024];
utf8_to_wchar(str, wstr, 1024);
return fwrite(wstr, wcslen(wstr), out);
}

So on windows the default error message we output is in wchar.
Maybe it should be converted to UTF8 when reading.
Or we could just output UTF8 without conversion, would that break anything?

errfile = joinpath(pfx, "stderr.txt")
@test libs_emptied > 0
@test_throws ProcessFailedException run(pipeline(`$pfx/bin/$(Base.julia_exename()) -e 'print("This should fail!\n")'`; stderr=errfile))
@test contains(readline(errfile), "ERROR: Unable to load dependent library")

@apaz-cli
Copy link
Member Author

According to my research, windows can display ascii or utf16 output in terminals, and as long as a single write call is used, it shouldn't matter which.

It seems like the test should detect if it's on Windows and read as utf16 instead?

@PallHaraldsson
Copy link
Contributor

Should this be reverted since causing CI errors elsewhere?

apaz-cli added a commit to apaz-cli/julia that referenced this pull request Oct 31, 2022
Fails on windows due to utf-16 conversion.

Test was introduced on PR JuliaLang#47343
DilumAluthge pushed a commit to apaz-cli/julia that referenced this pull request Oct 31, 2022
Fails on windows due to utf-16 conversion.

Test was introduced on PR JuliaLang#47343
apaz-cli added a commit to apaz-cli/julia that referenced this pull request Oct 31, 2022
We use loader_fputs to write error messages, and when
we write them to files we want those files to be utf8.

This should fix a broken test introduced in JuliaLang#47343.
apaz-cli added a commit to apaz-cli/julia that referenced this pull request Oct 31, 2022
We use loader_fputs to write error messages, and when
we write them to files we want those files to be utf8.

This should fix a broken test introduced in JuliaLang#47343.
vtjnash pushed a commit that referenced this pull request Nov 1, 2022
We use loader_fputs to write error messages, and when
we write them to files we want those files to be utf8.

This should fix a broken test introduced in #47343.
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.

Better error messages when libjulia-codegen fails to load
8 participants