question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: new reference is not decreased due to the `return NULL` statement in macro `import_array` (static analyzer reports)

See original GitHub issue

github_iconTop GitHub Comments

1reaction
Snape3058commented, May 22, 2022

@rgommers

What static analyzer are you running?

It is a new experimental checker for Clang Static Analyzer. And it is a part of my research that started in 2019 and has not been published yet.

And is this a regression, or is it the first time you ran your analysis?

The reports are from the first time I ran the analyzer on this project. Although these reports were legacy reports a couple of months ago, I have confirmed that such problems still exist in the latest version.

I’m not sure that is easy to change

Since I also found similar bugs in NumPy (issue 21532), I definitely know it is difficult and of low priority to fix such bugs. However, as an analyzer vendor and to satisfy my paper reviewers, I have to submit them to prove the effectiveness of my research.

I think the suggestion from @mckib2 seems to be a good idea and worth trying, as there are no data dependencies between import_array and the module you are initializing. Maybe we can also use this solution to fix the bugs in NumPy and its programming guidelines if it works for this project.

This is during extension module initialization, so if that fails there are larger problems than a leaking reference.

The developers of NumPy also said this. However, module importing can be wrapped with a try block, and a failed importing does not always means program termination (e.g. try an alternative module). Therefore, I think although it is of low priority, it is still worth fixing.

0reactions
Snape3058commented, Jun 14, 2022

@rgommers Thanks a lot. I will try my best to edit my paper and make it get published asap.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FAQ and How to Deal with Common False Positives
The analyzer reports a null dereference, but I know that the pointer is never null. How can I tell the analyzer that a...
Read more >
FAQ and How to Deal with Common ... - Apple Open Source
The analyzer reports a null dereference, but I know that the pointer is never null. How can I tell the analyzer that a...
Read more >
Null pointers should not be dereferenced - SonarSource Rules
A reference to null should never be dereferenced/accessed. Doing so will cause a NullPointerException to be thrown. At best, such an exception will...
Read more >
Solved: check if macro variable is null - SAS Communities
I need to set default value in case eg. var1 is null. To do this I need reliable method to check wether var1...
Read more >
Evaluating and Tuning a Static Analysis to Find Null Pointer ...
Using static analysis to detect memory access errors, such as null pointer dereferences, is not a new problem. However, much of the previous...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found