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

allow LIEF to fail when using patchelf #5176

Merged
merged 9 commits into from
Jul 16, 2024
Merged

Conversation

minrk
Copy link
Contributor

@minrk minrk commented Feb 9, 2024

avoids unconditional failure when LIEF raises, even when not used

Description

related to #5175, this allows LIEF to fail just like patchelf.

Previously, even when specifying method=patchelf, LIEF was unconditionally run. This adds error handling matching patchelf, so errors in an unused method don't prevent proceeding with patchelf.

avoids unconditional failure when LIEF raises, even when not used
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Feb 9, 2024
@minrk minrk mentioned this pull request Feb 9, 2024
5 tasks
@beeankha beeankha requested a review from a team as a code owner June 10, 2024 14:14
Copy link

codspeed-hq bot commented Jun 10, 2024

CodSpeed Performance Report

Merging #5176 will not alter performance

Comparing minrk:safe-lief-fail (a538ffd) with main (eca014a)

Summary

✅ 3 untouched benchmarks

Copy link
Member

@beeankha beeankha left a comment

Choose a reason for hiding this comment

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

Hi @minrk , thank you so much for this PR! A few things are requested (or are open for discussion) prior to merge:

  1. Is there any way that this code could be re-worked to use log.warn / log.error (with log = utils.get_logger(__name__)) for the error handling? I understand that you most likely wanted to remain consistent with the rest of the mk_relative_linux function, but we can take this opportunity to improve error handling patterns (if you feel inclined to do so!)

  2. It would be great to see a test or two for this change; addtionally it might help to have more details in the PR description for steps on how to reproduce LIEF being unconditionally run even when method=patchelf was specified

  3. Please add a news file with a brief description of this change

@minrk
Copy link
Contributor Author

minrk commented Jun 21, 2024

I switched it to log and added news. I'm afraid I don't know how to exercise this failure in a test.

@beeankha beeankha self-requested a review June 28, 2024 13:35
news/5176-lief-fail Outdated Show resolved Hide resolved
beeankha
beeankha previously approved these changes Jun 28, 2024
@jaimergp
Copy link
Contributor

Hm, the modified function is now using two different methods to report errors and warnings to the user. This implies slightly different formats, and also different streams (logging will print to stderr and print to stdout, as currently configured). I'd rather stick to one of the methods so:

  • Either change everything to logging (and move logger to the top-level module namespace, under the imports)
  • Revert to print with the same format as the other messages. We would need to create an issue to tackle a general move to logging, if one doesn't exist yet

@beeankha
Copy link
Member

Per Jaime's comment, I reverted the logging changes; I also went ahead and filed an issue to change all error-reporting to logging.

print(
f"ERROR :: get_rpaths_raw({elf!r}) with LIEF failed: {e}, but LIEF was specified"
)
traceback.print_tb(e.__traceback__)
Copy link
Contributor

Choose a reason for hiding this comment

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

Apparently this prints to stderr by default. Just mentioning for awareness. I'm not sure if we should print to stdout for consistency or not.

@kenodegard kenodegard enabled auto-merge (squash) July 15, 2024 22:33
@kenodegard kenodegard merged commit 1d771ad into conda:main Jul 16, 2024
28 checks passed
@beeankha beeankha mentioned this pull request Jul 16, 2024
55 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants