Skip to content
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

8307145: windowsaccessbridge.dll erroneously includes private methods in its C API #13734

Closed
wants to merge 5 commits into from

Conversation

TheShermanTanker
Copy link
Contributor

@TheShermanTanker TheShermanTanker commented Apr 29, 2023

In windowsaccessbridge(-64).dll the following methods are exported in a def file to C API which in turn call their real implementation, which are instance methods of the class WinAccessBridge:

addJavaEventNotification
removeJavaEventNotification
addAccessibilityEventNotification
removeAccessibilityEventNotification

However, they are nowhere to be seen in the actual C interface, in AccessBridgeWindowsEntryPoints.cpp. Your guess is as good as mine as to how on earth MSVC is still capable of compiling and linking this without any errors whatsoever, but in any case, this is a severe oversight and should be properly defined in the C API lest this happy accident within MSVC is fixed by Microsoft in the future


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8307145: windowsaccessbridge.dll erroneously includes private methods in its C API (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13734/head:pull/13734
$ git checkout pull/13734

Update a local copy of the PR:
$ git checkout pull/13734
$ git pull https://git.openjdk.org/jdk.git pull/13734/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13734

View PR using the GUI difftool:
$ git pr show -t 13734

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13734.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 29, 2023

👋 Welcome back jwaters! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 29, 2023
@openjdk
Copy link

openjdk bot commented Apr 29, 2023

@TheShermanTanker The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Apr 29, 2023
@mlbridge
Copy link

mlbridge bot commented Apr 29, 2023

Webrevs

Copy link
Contributor

@prrace prrace left a comment

Choose a reason for hiding this comment

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

These don't seem to be part of the public API, so this is probably deliberate and not a bug.
https://docs.oracle.com/javase/accessbridge/2.0.2/api.htm#jab-api-specification

@NikitkoCent
Copy link
Contributor

These don't seem to be part of the public API, so this is probably deliberate and not a bug.
https://docs.oracle.com/javase/accessbridge/2.0.2/api.htm#jab-api-specification

@prrace should non-public API methods be removed from .DEF then?

@TheShermanTanker
Copy link
Contributor Author

I should think so, it doesn't make sense to export a function that doesn't even exist at all. And to make matters worse Microsoft Visual C still does export functions with those names (you can easily verify this with dumpbin) which is even more confusing. It may be a cursed Microsoft extension that has simply gone under the radar, and is somehow exporting the C++ class instance methods as static, or even exporting dummy functions, neither of which is what we want it to do!

@prrace
Copy link
Contributor

prrace commented May 3, 2023

So perhaps something internal in the various accessbridge dll's needs it. How will you test this ?
Who here has JAWS ? If you don't have JAWS and therefore can't use it to verify the A11Y test suite then
I don't think you can test this change in a way that makes me comfortable in doing anything here.

@savoptik
Copy link
Contributor

savoptik commented May 3, 2023

@prrace Maybe try using free NVDA for testing?

@TheShermanTanker
Copy link
Contributor Author

The problem as I see it is that the .def is exporting something that simply does not exist at all, even if it is a non-public API and the symbols are simply exported from the DLL for internal use by other accessbridge code, then these methods should still be placed in the extern "C" block in the .cpp (but maybe not in the corresponding header since they aren't public). Conversely if it is never meant to be exported but the accessbridge DLLs somehow need the .def files to export phantom, nonexistent symbols to work properly, then something is seriously wrong with them and we should probably take a look at what on earth is going on there

@djelinski
Copy link
Member

FWIW, this is what dumpbin displays for these entries:

          1    2 0000351C addAccessibilityEventNotification = ?addAccessibilityEventNotification@WinAccessBridge@@QEAAX_J@Z (public: void __cdecl WinAccessBridge::addAccessibilityEventNotification(__int64))
          2    4 00003628 addJavaEventNotification = ?addJavaEventNotification@WinAccessBridge@@QEAAX_J@Z (public: void __cdecl WinAccessBridge::addJavaEventNotification(__int64))
          3   42 00006D94 removeAccessibilityEventNotification = ?removeAccessibilityEventNotification@WinAccessBridge@@QEAAX_J@Z (public: void __cdecl WinAccessBridge::removeAccessibilityEventNotification(__int64))
          4   44 00006EA0 removeJavaEventNotification = ?removeJavaEventNotification@WinAccessBridge@@QEAAX_J@Z (public: void __cdecl WinAccessBridge::removeJavaEventNotification(__int64))

There's no way to get a pointer to an instance of WinAccessBridge using the supported interface, and calling these methods with garbage value for this would likely crash.

@TheShermanTanker
Copy link
Contributor Author

FWIW, this is what dumpbin displays for these entries:

          1    2 0000351C addAccessibilityEventNotification = ?addAccessibilityEventNotification@WinAccessBridge@@QEAAX_J@Z (public: void __cdecl WinAccessBridge::addAccessibilityEventNotification(__int64))
          2    4 00003628 addJavaEventNotification = ?addJavaEventNotification@WinAccessBridge@@QEAAX_J@Z (public: void __cdecl WinAccessBridge::addJavaEventNotification(__int64))
          3   42 00006D94 removeAccessibilityEventNotification = ?removeAccessibilityEventNotification@WinAccessBridge@@QEAAX_J@Z (public: void __cdecl WinAccessBridge::removeAccessibilityEventNotification(__int64))
          4   44 00006EA0 removeJavaEventNotification = ?removeJavaEventNotification@WinAccessBridge@@QEAAX_J@Z (public: void __cdecl WinAccessBridge::removeJavaEventNotification(__int64))

There's no way to get a pointer to an instance of WinAccessBridge using the supported interface, and calling these methods with garbage value for this would likely crash.

Dear lord, the Microsoft linker is truly cursed, through and through

@prrace What sort of testing would need to be done for such a change?

@prrace
Copy link
Contributor

prrace commented May 5, 2023

FWIW, this is what dumpbin displays for these entries:

          1    2 0000351C addAccessibilityEventNotification = ?addAccessibilityEventNotification@WinAccessBridge@@QEAAX_J@Z (public: void __cdecl WinAccessBridge::addAccessibilityEventNotification(__int64))
          2    4 00003628 addJavaEventNotification = ?addJavaEventNotification@WinAccessBridge@@QEAAX_J@Z (public: void __cdecl WinAccessBridge::addJavaEventNotification(__int64))
          3   42 00006D94 removeAccessibilityEventNotification = ?removeAccessibilityEventNotification@WinAccessBridge@@QEAAX_J@Z (public: void __cdecl WinAccessBridge::removeAccessibilityEventNotification(__int64))
          4   44 00006EA0 removeJavaEventNotification = ?removeJavaEventNotification@WinAccessBridge@@QEAAX_J@Z (public: void __cdecl WinAccessBridge::removeJavaEventNotification(__int64))

There's no way to get a pointer to an instance of WinAccessBridge using the supported interface, and calling these methods with garbage value for this would likely crash.

Dear lord, the Microsoft linker is truly cursed, through and through

@prrace What sort of testing would need to be done for such a change?

@azuev-java and @kumarabhi006 can help with review and testing of this PR.

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 2, 2023

@TheShermanTanker This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@TheShermanTanker
Copy link
Contributor Author

Bumping

@TheShermanTanker
Copy link
Contributor Author

Anyone?

@aivanov-jdk
Copy link
Member

I'll take a look… hopefully next week.

@TheShermanTanker
Copy link
Contributor Author

Thanks aivanov, no rush haha

@TheShermanTanker
Copy link
Contributor Author

Bumping

@aivanov-jdk
Copy link
Member

These don't seem to be part of the public API, so this is probably deliberate and not a bug.
https://docs.oracle.com/javase/accessbridge/2.0.2/api.htm#jab-api-specification

@prrace should non-public API methods be removed from .DEF then?

I think it's the best solution. These four functions are not part of the public API to AccessBridge, they're missing from AccessBridgeCalls.c and AccessBridgeCalls.h.

They should not be exported. If the functions aren't loaded by its name, which is implemented in AccessBridgeCalls.c, or otherwise linked to from other modules (.exe or .dll), they don't need to be exported. These functions are part of the WinAccessBridge class, none of them cannot be called directly.

Did you try removing them from the .def file? Does anything break?

@TheShermanTanker
Copy link
Contributor Author

@aivanov-jdk Compiles and works fine without the exports in .def

@TheShermanTanker
Copy link
Contributor Author

I don't know about the more extensive test suite Phil alludes to, though

@TheShermanTanker
Copy link
Contributor Author

Bumping

@aivanov-jdk
Copy link
Member

I don't know about the more extensive test suite Phil alludes to, though

Neither do I know about more extensive testing. I presume these four entry points were not used externally. Yet “compiles” may not be enough. What does your “works” mean? Did you run it with an AccessBridge client?

@TheShermanTanker
Copy link
Contributor Author

@aivanov-jdk The client does indeed function on my end without issue, but I don't know whether it will do so on other devices as well

@TheShermanTanker
Copy link
Contributor Author

JTReg sure does have a sense of humour, immediately crashing and leaving that ugly cross on the tests the moment I say that

Copy link
Member

@djelinski djelinski left a comment

Choose a reason for hiding this comment

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

LGTM. These methods are not usable outside of the windowsaccessbridge dll. Caller would need a working instance of WinAccessBridge class to pass in this parameter, and there's no way to get one outside of the DLL.

@openjdk
Copy link

openjdk bot commented Jun 21, 2023

@TheShermanTanker This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8307145: windowsaccessbridge.dll erroneously includes private methods in its C API

Reviewed-by: djelinski

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 774 new commits pushed to the master branch:

  • 47d00a4: 8310265: (process) jspawnhelper should not use argv[0]
  • e022e87: 8310053: VarHandle and slice handle derived from layout are lacking alignment check
  • 45eaf5e: 8298443: Remove expired flags in JDK 22
  • 28415ad: 8310225: Reduce inclusion of oopMapCache.hpp and generateOopMap.hpp
  • 4c3efb3: 8309034: NoClassDefFoundError when initializing Long$LongCache
  • 1120106: 8310458: Fix build failure caused by JDK-8310049
  • 09174e0: 8310049: Refactor Charset tests to use JUnit
  • 99d2a9a: 8310330: HttpClient: debugging interestOps/readyOps could cause exceptions and smaller cleanup
  • 31b6fd7: 8309258: RISC-V: Add riscv_hwprobe syscall
  • 4a9cc8a: 8309266: C2: assert(final_con == (jlong)final_int) failed: final value should be integer
  • ... and 764 more: https://git.openjdk.org/jdk/compare/6d6d00b69cea47ccbe05a844db0fb6c384045caa...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 21, 2023
@TheShermanTanker
Copy link
Contributor Author

Right, thanks Daniel

@TheShermanTanker
Copy link
Contributor Author

I will change the title of the PR first

@TheShermanTanker TheShermanTanker changed the title 8307145: windowsaccessbridge.dll is missing 4 critical methods in its C API 8307145: windowsaccessbridge.dll erroneously includes private methods in its C API Jun 21, 2023
@TheShermanTanker
Copy link
Contributor Author

/integrate

@TheShermanTanker
Copy link
Contributor Author

Thanks all for reviewing this change!

@openjdk
Copy link

openjdk bot commented Jun 21, 2023

Going to push as commit 3faba07.
Since your change was applied there have been 775 commits pushed to the master branch:

  • 886ac1c: 8308606: C2 SuperWord: remove alignment checks when not required
  • 47d00a4: 8310265: (process) jspawnhelper should not use argv[0]
  • e022e87: 8310053: VarHandle and slice handle derived from layout are lacking alignment check
  • 45eaf5e: 8298443: Remove expired flags in JDK 22
  • 28415ad: 8310225: Reduce inclusion of oopMapCache.hpp and generateOopMap.hpp
  • 4c3efb3: 8309034: NoClassDefFoundError when initializing Long$LongCache
  • 1120106: 8310458: Fix build failure caused by JDK-8310049
  • 09174e0: 8310049: Refactor Charset tests to use JUnit
  • 99d2a9a: 8310330: HttpClient: debugging interestOps/readyOps could cause exceptions and smaller cleanup
  • 31b6fd7: 8309258: RISC-V: Add riscv_hwprobe syscall
  • ... and 765 more: https://git.openjdk.org/jdk/compare/6d6d00b69cea47ccbe05a844db0fb6c384045caa...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 21, 2023
@openjdk openjdk bot closed this Jun 21, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 21, 2023
@openjdk
Copy link

openjdk bot commented Jun 21, 2023

@TheShermanTanker Pushed as commit 3faba07.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@TheShermanTanker TheShermanTanker deleted the patch-7 branch June 21, 2023 06:43
@aivanov-jdk
Copy link
Member

@aivanov-jdk The client does indeed function on my end without issue, but I don't know whether it will do so on other devices as well

That's good to know.

I would've approved it, if I'd had a slightest chance to read your reply.

@TheShermanTanker
Copy link
Contributor Author

Ah, sorry about that. I've had several changes starved of reviews recently and lying around for almost a month, and was feeling fairly frustrated and impatient :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

6 participants