-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Runtime errors with undefined behaviour sanitizer #3176
Comments
Looks like Could you please clarify, does the sanitizer hit an error there, or just speculates that there might be one? |
The sanitizer just says that it is an error (well, it says that this is undefined behaviour by the standard), but the code otherwise runs fine when I disable the sanitizer. It's probably one of those cases where the standard says it's UB but every compiler considers it to be ok. It's not blocking for my project, but it means that I need to manually generate suppression files for code that is otherwise expected to work correctly if I want to leverage the power of ubsan to find actual bugs in the code I inherited. |
From the inheritance diagram I'm not fully convinced the cast is required. |
I tried removing the cast, and everything seems to work fine (without ubsan). When I compile with ubsan the error isn't triggered anymore, but it chokes on another It seems that using PCL with |
Unfortunately I few lines later we cast it again to call @SergioRAgostinho would you be open to a bit of refactoring here? I see two possibilities. First one is to change the signature to accept |
We can probably resort to vtk's casting mechanisms Is it possible to "adopt both"? Change the signature of the current method to |
Maybe it's also worth adding jobs with sanitizers to the continuous integration? |
We can experiment with this on the further problems reported by ubsan.
Possible. The I would go further and in the new signature return smart pointer instead of taking it by reference. |
That's an interesting option. But would be very low on my todo list to be honest, just don't have time for this. |
@Morwenn we've merged a PR that fixes the problem you reported. Could you have another try with UB? |
I'm trying to build PCL with master but it might take longer than expected because I'm using |
Please check the output of CMake, it may be that OpenNI2 is not found despite you enabling it. |
OpenNI2 is correctly found (I'm using Conan, hence the long links):
It worked correctly with PCL 1.9.1, so I'm surprised that it doesn't with the master branch (I'd point my finger at the CMake overhaul for 1.10, but I can't really be sure). Also I couldn't find the file responsible for defining |
It gets configured here. Line 451 in 10991fa
Line 27 in 10991fa
This will also help. https://cmake.org/cmake/help/v3.5/command/configure_file.html Is |
I just checked and it's correctly defined in EDIT: found it, this commit is responsible for the issue: 9f7a246#diff-a7a89f9d2f1d1031a32f09984d839d29 |
That's a bug indeed, thanks for identifying and sorry for the trouble. |
I can confirm that the fix for OpenNI2 works, thanks a lot for being so reactive :) On the other hand, the undefined behaviour sanitizer still produces an error in the same function, albeit not at the same place:
I'm even more surprised than before considering that there is not cast involved and everything compiles properly. The affected line is the following one: scalars->SetNumberOfComponents (3); Unfortunately I probably won't have time to deal with those errors in my current project, so I will most likely give up on trying to use the undefined behaviour sanitizer for now. Thanks again for your time! |
Hm, weird. OK, I will close this for now. Feel free to re-open if you find time to investigate this further. |
Your Environment
Context
I tried to run a program using PCL with the undefined behaviour sanitizer and was hit with a runtime error. I don't know whether it's genuine or whether PCL does clever things that might warrant adding a suppression file.
Current Behavior
I inherited some C++ code using PCL and tried to run it with address sanitizers and undefined behaviour sanitizer, but after fixing errors on our side, I eventually got hit with this one which comes from PCL (triggered by the
vptr
check of ubsan):The line from
point_cloud_color_handlers.hpp
which triggers the ubsan error is the following one:Considering that
scalars
is declared asvtkSmartPointer<vtkDataArray> &
I wouldn't be surprised if the error came from thereinterpret_cast
.Code to Reproduce
I'm unfortunately not sure where it comes from in the code I inherited, but considering that the suspicious line contains a
reinterpret_cast
, I would expect the PCL code to be responsible for the runtime error.Possible Solution
Either it can be fixed or PCL can ship a suppression file for the undefined behaviour sanitizer.
The text was updated successfully, but these errors were encountered: