Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sarlinpe
Copy link
Member

  • This is a rework of PR Switch to exception checks #2371 that is much less intrusive - we simply overwrite the glog macros to throw instead of aborting
  • I checked with valgrind that this doesn't incur any memory leak
  • Folks that depend on COLMAP not throwing exception can easily add an ifdef to disable this behavior
  • I will remove the now-unnecessary pycolmap checks in a later PR

cc @Phil26AT

@ahojnnes
Copy link
Contributor

One drawback here. Imagine the following setup:

#include "colmap/util/logging.h"

#include <ExternalLibraryThatUsesGlogInHeader.h>

This will blow up when that external library uses glog's check macros in a way that our overrides don't support (e.g., CHECK(condition) << "message";.

This can also happen when colmap is installed as a library and other code uses glog. The v1 version of your PR added more code but does not have that problem?

@sarlinpe
Copy link
Member Author

As opposed to the previous PR, this one actually retains the syntax of glog by only overriding the internals. So CHECK(condition) << "message"; remains valid and any library using it in headers will simply throw an exception instead of aborting. If you think that this is confusing, we can:

  1. Make this behavior optional with a CMake option, or
  2. Name the macros differently to retain the behavior of glog's original checks

@ahojnnes
Copy link
Contributor

If option (2) is possible, then that sounds great to me and nobody sees unexpected behavior when using glog macros?

@sarlinpe
Copy link
Member Author

Done, PTAL.

@ahojnnes
Copy link
Contributor

ahojnnes commented Feb 1, 2024

Great, thanks!

@ahojnnes ahojnnes enabled auto-merge (squash) February 1, 2024 06:59
@ahojnnes ahojnnes merged commit b4103ec into colmap:main Feb 1, 2024
@sarlinpe sarlinpe deleted the sarlinpe/exception-checks-v2 branch February 1, 2024 08:23
@sarlinpe sarlinpe mentioned this pull request Feb 2, 2024
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.

2 participants