-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
IGRAPH_FINALLY()
and IGRAPH_FINALLY_REAL()
#1613
Comments
I think it is highly unreasonable to try to work around this warning, which can easily be disabled: We already knew that this warning existed, understand the reasons, and know that it is harmless. I can also say right now that this is not the only UBSan warning we have. |
Right, I hear you. How about: do { \
/* the following branch makes the compiler check the compatibility of \
* func and ptr to detect cases when we are accidentally invoking an \
* incorrect destructor function with the pointer */ \
if (0) { func(ptr); } \
IGRAPH_FINALLY_REAL((func##_pv), (ptr)); \
} while (0) Note the Arguing with CRAN is an uphill battle. |
Let's hear from @ntamas as well. At this point my opinion is that we need to try to talk reason into CRAN, but let's discuss the objective part below. The change you propose (which preserves useful compiler warnings) is to duplicate every single destructor and provide a version (
An alternative (and also breaking) solution is to make destructors take a It seems that CRAN is starting to complain about UBSan warnings. It's important to note that:
Especially when working with limited resources, we can't afford to put multiple days of work into changes that bring no objective improvements, and are even potentially harmful (increased complexity, harder to use library, higher maintenance costs). I am leaving tomorrow morning and wouldn't even be able to look at this (many hours of work) for 2 weeks. I can write up an explanation that can be relayed to CRAN though. |
The R package could define its own I agree it's a moving target, but I'd rather just do the work (in the R package) than argue about it. It seems manageable. What is the alternative? Not have it on CRAN? Silence the test (by not running examples at all)? |
My two cents:
So, if I were to call the shots, I'd probably say let's try to work around it in the R interface if we can limit the changes required to the R interface only, and we have the resources to deal with it. This is just an intrinsic part of the maintenance cost of the R interface, which is admittedly higher than what I need to invest in the Python interface to get the next version accepted in PyPI. You can try to argue, but be prepared for a long uphill battle with no guaranteed outcome and arbitrarily long delays for the next igraph release in CRAN. |
The problem is that practically it's impossible to isolate these changes from the C core. We can say that we'll limit the changes to the R interface, but that doesn't eliminate the coupling between the two sides. This means that the workaround is still costly to implement, costly to maintain, and there will be more kinds of changes on the C core side that will necessitate a response on the R side, which is not ideal. Anyway, let's make a decision. It sounds like we sort-of have an agreement not to make changes in the C core. Correct me if I'm wrong. @krlmlr, do you still want to do this workaround on the R side then, or do you want to try to convince CRAN first? If you will try to convince CRAN, do you need some explanatory text? If you intend to go with the code generation route, we can do something like trying to guarantee that all destructors have a predictable name, such as |
Final thought: This issue affects not only public destructors, but also private ones, so parsing headers will never be enough. However, it occurs only during error handling, which is rare in the R test suite and in examples. Thus just to pass CRAN's tests we don't need to "fix" every single occurrence, affecting every private destructor. |
FYI I just ran the C test suite with UBSan, which I do periodically, and fixed the single (harmless) warning that came up. CRAN is clearly enabling some non-default UBSan warnings though, and making UBSan warnings errors (instead of the default warning), so be prepared for much more ... In particular, be prepared for complaints about conversions between float/integer, which is the hack we use in the R interface for checking whether a float value is representable as integer in a performant way. Fixing that issue will no doubt ave a performance cost once these checks start getting applied to vectors as well as scalar, something that I believe is necessary to do. rigraph/src/rinterface_extra.c Line 80 in 7414602
|
You can also consider disabling this using a pragma, in a localized way. This is easy, and won't disable the warnings in places where the same issue may potentially be harmful. |
Thanks. Agree to keep the changes local to the R package. I can hand-roll the few Re integerness check: is this really faster than calling CRAN checks for pragmas. |
We use this function in a format reader, where it is not performance critical. I believe that using this will be significantly slower than the back-and-forth cast we use in R now, but I have not benchmarked this. |
Earlier, I wondered if This is not for right now, it looks like we can push 2.1.2, but we'd want to address it for the subsequent version. |
I'm not in favour of including them in the C core, but we can hear what @ntamas has to say. If you decide to go ahead with the solution you propose, I suggest attempting to auto-generate these ONCE and include them in a single file that's checked into the rigraph repo. There may be issues with destructors declared as I might be able to give the auto-generation a go at some point, but I'd do this in Mathematica (my comfort zone), so it'd be a one-time thing, leaving future updates to be done manually. The plan is to use |
CSan checks complain about our hack in
IGRAPH_FINALLY()
callingIGRAPH_FINALLY_REAL()
with a cast function pointer: https://github.com/igraph/rigraph/actions/runs/12108577215/job/33756736066#step:6:10130 . My most recent submission got rejected from CRAN because of this.Propose to only use
IGRAPH_FINALLY_REAL()
instead ofIGRAPH_FINALLY()
in the R interface, and create wrapper functions for each function called:(For some
magic_cast
we'd have to figure out. I can't quite parseigraph_vector.h
. These days, I'd write a code generator and commit the generated code to version control, instead of this complex preprocessor logic because I find that easier to read.)@szhorvat @ntamas: What do you think?
The text was updated successfully, but these errors were encountered: