close
Skip to content

Reworked disabling error windows by introducing new defines so that we can more eas…#2352

Merged
jwillemsen merged 2 commits intoDOCGroup:masterfrom
jwillemsen:jwi-objmanagerdfei
Mar 11, 2025
Merged

Reworked disabling error windows by introducing new defines so that we can more eas…#2352
jwillemsen merged 2 commits intoDOCGroup:masterfrom
jwillemsen:jwi-objmanagerdfei

Conversation

@jwillemsen
Copy link
Copy Markdown
Member

@jwillemsen jwillemsen commented Mar 11, 2025

…ily enable the code for Embarcadero C++ Builder

* ACE/ace/Object_Manager.cpp:
* ACE/ace/config-win32-borland.h:
* ACE/ace/config-win32-mingw.h:
* ACE/ace/config-win32-mingw64.h:
* ACE/ace/config-win32-msvc.h:

Summary by CodeRabbit

  • New Features
    • Enhanced Windows error reporting and exception handling to improve debugging behavior and system reliability.
    • Streamlined configuration across various Windows build environments for consistent performance.
  • Tests
    • Added a new test focused on verifying structured exception handling, ensuring stable runtime behavior on Windows platforms.

…ily enable the code for Embarcadero C++ Builder

    * ACE/ace/Object_Manager.cpp:
    * ACE/ace/config-win32-borland.h:
    * ACE/ace/config-win32-mingw.h:
    * ACE/ace/config-win32-mingw64.h:
    * ACE/ace/config-win32-msvc.h:
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 11, 2025

Walkthrough

This pull request modifies the conditional compilation in the Windows-specific error reporting mechanism of the ACE_Object_Manager. It streamlines the conditions by relying solely on _DEBUG with the new ACE_HAS_CRTSETREPORTMODE macro and refines the unhandled exception filter check for Intel-based builds. Additionally, new preprocessor definitions are added in several Windows configuration files, and a new test, Compiler_Features_41_Test, is introduced to verify structured exception handling support.

Changes

File(s) Change Summary
ACE/ace/Object_Manager.cpp Modified conditional compilation in ACE_Object_Manager::init() to use _DEBUG with ACE_HAS_CRTSETREPORTMODE and adjusted the check for unhandled exception filter using ACE_HAS_SETUNHANDLEDEXCEPTIONFILTER and _M_IX86.
ACE/ace/config-win32-{borland, mingw, mingw64, msvc}.h Added new preprocessor directives: #define ACE_HAS_CRTSETREPORTMODE and #define ACE_HAS_SETUNHANDLEDEXCEPTIONFILTER to enable specific CRT error reporting and exception handling features.
ACE/tests/{Compiler_Features_41_Test.cpp, run_test.lst, tests.mpc} Introduced a new test for structured exception handling; added Compiler_Features_41_Test source, test list entry, and project definition.

Sequence Diagram(s)

sequenceDiagram
    participant TestRunner as Test Runner
    participant SEHBlock as SEH Block
    participant Logger as Logger

    TestRunner->>Logger: Check for SEH support via ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS
    alt SEH Supported
        TestRunner->>SEHBlock: Enter ACE_SEH_TRY block
        SEHBlock->>TestRunner: Trigger access violation (null pointer)
        TestRunner->>SEHBlock: Transition to ACE_SEH_FINALLY block
        SEHBlock->>Logger: Log execution of finally block
        TestRunner->>Logger: Report test passed
    else SEH Not Supported
        TestRunner->>Logger: Log non-support of SEH
    end
Loading

Possibly related PRs

Poem

I'm just a rabbit with a curious hop,
Leaping through code changes non-stop.
New macros bloom in the config files, so neat,
And SEH tests march to their rhythmic beat.
Hoppity cheers for code that’s so fine—
Happy to nibble on updates divine!
🐇🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eac06af and a6dd3c9.

📒 Files selected for processing (8)
  • ACE/ace/Object_Manager.cpp (3 hunks)
  • ACE/ace/config-win32-borland.h (1 hunks)
  • ACE/ace/config-win32-mingw.h (1 hunks)
  • ACE/ace/config-win32-mingw64.h (1 hunks)
  • ACE/ace/config-win32-msvc.h (1 hunks)
  • ACE/tests/Compiler_Features_41_Test.cpp (1 hunks)
  • ACE/tests/run_test.lst (1 hunks)
  • ACE/tests/tests.mpc (1 hunks)
🔇 Additional comments (8)
ACE/ace/config-win32-mingw.h (1)

91-92: Well-structured addition of preprocessor definitions for Windows error handling support.

The addition of ACE_HAS_CRTSETREPORTMODE and ACE_HAS_SETUNHANDLEDEXCEPTIONFILTER definitions will enable conditional compilation of Windows-specific error reporting and exception handling features. This aligns with the PR objective to better support Embarcadero C++ Builder.

ACE/ace/config-win32-borland.h (1)

96-97: Good addition of matching preprocessor definitions for Borland compiler configuration.

These definitions match those added to the MinGW configuration, ensuring consistent cross-compiler support for CRT report mode configuration and structured exception handling. This is particularly relevant for Embarcadero C++ Builder which is derived from Borland's compiler technology.

ACE/tests/run_test.lst (1)

114-114: Appropriate addition of new compiler feature test.

The new Compiler_Features_41_Test entry follows the naming convention of existing compiler feature tests and is correctly positioned in the list. Based on the PR description, this test likely verifies structured exception handling support which is essential for validating the new macros.

ACE/tests/tests.mpc (1)

859-864: Well-structured test project definition that matches existing patterns.

The new project definition for Compiler_Features_41_Test follows the same structure as the other compiler feature tests, inheriting from the acetest base project and properly specifying the executable name and source file.

ACE/ace/config-win32-mingw64.h (1)

112-113: Enhanced cross-compiler compatibility with new preprocessor definitions

These new defines align with similar additions in other configuration files, improving the code's ability to work with different Windows compilers, including Embarcadero C++ Builder. The definitions correctly isolate platform-specific capabilities:

  • ACE_HAS_CRTSETREPORTMODE: Controls CRT debug error reporting availability
  • ACE_HAS_SETUNHANDLEDEXCEPTIONFILTER: Indicates support for Windows exception filter handling
ACE/ace/config-win32-msvc.h (1)

113-114: Consistent definition pattern applied to MSVC configuration

These definitions match those added to other platform configurations, ensuring a uniform approach to compiler feature detection across different Windows platforms. The defines are appropriately placed after the existing structured exceptions support define.

ACE/ace/Object_Manager.cpp (2)

261-266: Simplified conditional compilation for debug reporting

The code now relies on the new ACE_HAS_CRTSETREPORTMODE define rather than checking multiple compiler-specific macros, improving maintainability and making the code more adaptable to different compilers including Embarcadero C++ Builder.


279-291: Improved documentation for security-related CRT behavior

The comments have been reformatted and clarified to better explain the workaround for Microsoft's CRT behavior changes in security contexts. This provides valuable context for future maintainers.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🧹 Nitpick comments (1)
ACE/ace/Object_Manager.cpp (1)

292-317: Enhanced conditional compilation for exception filter handling

The code now uses the new ACE_HAS_SETUNHANDLEDEXCEPTIONFILTER define along with architecture checking to properly isolate Intel x86-specific code. This makes the implementation more robust and maintainable.

One suggestion to improve readability:

The comment on line 292 indicating "this only works for intel based windows builds" could be made clearer by mentioning that it's specifically for 32-bit Intel (x86) architectures, not 64-bit (x64/AMD64). Consider:

-  // NOTE this only works for intel based windows builds.
+  // NOTE: This only works for 32-bit Intel (x86) Windows builds, not 64-bit (x64/AMD64).
🛑 Comments failed to post (1)
ACE/tests/Compiler_Features_41_Test.cpp (1)

1-61: 🛠️ Refactor suggestion

Well-structured test for SEH functionality

This test effectively verifies structured exception handling (SEH) support, which is relevant to the PR's modifications around exception handling. The implementation follows good practices:

  1. The test is properly guarded with ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS to ensure it only runs on supported platforms
  2. It uses deliberate null pointer dereference to test SEH handling
  3. It verifies that the FINALLY block executes as expected

However, there is a potential issue with the test's recovery mechanism:

The test intentionally causes an access violation but doesn't include an explicit try/catch or SEH EXCEPT block to handle the exception. While the FINALLY block will execute, the test might still crash on some platforms depending on how SEH is implemented.

Consider either:

  1. Adding explicit exception handling with ACE_SEH_EXCEPT to catch the exception, or
  2. Adding a comment explaining why this approach is safe across all targeted platforms
 ACE_SEH_TRY
   {
     ACE_DEBUG ((LM_DEBUG,("In SEH_TRY\n")));

     // Intentionally cause an access violation exception
     char *cause_exception {};
     *cause_exception = 'x';  // Should raise an exception

     // If we get here without an exception, SEH isn't working
     ACE_ERROR ((LM_ERROR, "No exception was raised from null pointer dereference\n"));
     result = -1;
   }
+ACE_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+  {
+    // Exception was caught as expected
+    ACE_DEBUG ((LM_DEBUG, "Exception caught as expected\n"));
+  }
 ACE_SEH_FINALLY
   {
     ACE_DEBUG ((LM_DEBUG,("In SEH_FINALLY\n")));
     finally_executed = true;
     // If we're here due to an exception, that's the expected behavior - test passes
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

/**
 * This program checks if the compiler/RTL does have correct support
 * for structured exception handling using __try/__finally
 */

#include "test_config.h"

int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT("Compiler_Features_41_Test"));
  int result = 0;

#if defined (ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS)
  bool finally_executed = false;

  ACE_DEBUG ((LM_DEBUG,("Testing __try/__finally\n")));

  ACE_SEH_TRY
    {
      ACE_DEBUG ((LM_DEBUG,("In SEH_TRY\n")));

      // Intentionally cause an access violation exception
      char *cause_exception {};
      *cause_exception = 'x';  // Should raise an exception

      // If we get here without an exception, SEH isn't working
      ACE_ERROR ((LM_ERROR, "No exception was raised from null pointer dereference\n"));
      result = -1;
    }
  ACE_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
      // Exception was caught as expected
      ACE_DEBUG ((LM_DEBUG, "Exception caught as expected\n"));
    }
  ACE_SEH_FINALLY
    {
      ACE_DEBUG ((LM_DEBUG,("In SEH_FINALLY\n")));
      finally_executed = true;
      // If we're here due to an exception, that's the expected behavior - test passes
    }

  ACE_DEBUG ((LM_DEBUG,("After SEH_FINALLY\n")));

  // On successful SEH handling:
  // 1. The null pointer dereference should raise an exception
  // 2. The FINALLY block should execute
  // 3. Execution should continue after the SEH blocks
  if (finally_executed)
  {
    ACE_DEBUG ((LM_DEBUG, "SEH test passed - FINALLY block was executed\n"));
  }
  else
  {
    ACE_ERROR ((LM_ERROR, "SEH test failed - FINALLY block was not executed\n"));
    result = -1;
  }
#else
  ACE_DEBUG ((LM_INFO,
              ACE_TEXT ("Platform lacks ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS\n")));
#endif /* ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS */

  ACE_END_TEST;

  return result;
}

@jwillemsen jwillemsen changed the title Reworked some code by introducing new defines so that we can more eas… Reworked disabling error windows by introducing new defines so that we can more eas… Mar 11, 2025
@jwillemsen jwillemsen merged commit 5ab19ea into DOCGroup:master Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant