Uh oh!
There was an error while loading. Please reload this page.
Fix #41618 Correct marshalling of SortKey objects on Linux - #65548
Conversation
ghost
commented
Feb 18, 2022
Tagging subscribers to this area: @dotnet/area-system-directoryservices, @jay98014 Issue DetailsThe
|
lscorcia
commented
Feb 28, 2022
Hello @joperezr , what do you think about this? |
joperezr
commented
Feb 28, 2022
Thanks a lot for the contribution @lscorcia, I'm very sorry that it took a bit for me to take a look at this. |
joperezr
commented
Feb 28, 2022
@lscorcia would it be possible to also add a functional test which performs a search and uses the sort control here: https://github.com/dotnet/runtime/blob/main/src/libraries/System.DirectoryServices.Protocols/tests/DirectoryServicesProtocolsTests.cs ? Those tests don't run in our builds, but we run them manually every now and then against a real LdapServer so it would be good to get protection against this to ensure it works as expected in all platforms. |
joperezr
commented
Feb 28, 2022
The changes LGTM, but I'm adding @bartonjs to take a look first because he is much more familiar with PInvoke marshalling in general, but also because SortKey is a public type and even though I believe that changing the StructLayout isn't a breaking change, I want to make sure we double check. |
Uh oh!
There was an error while loading. Please reload this page.
joperezr
commented
Mar 1, 2022
I see, yeah that makes sense, I think it is fine to create an internal struct (that uses the appropriate charset depending on the platform) which is then used for PInvoking is better and we should leave SortKey as is, and just use it to copy the values into that internal struct. @lscorcia would you be able to adjust this PR to do what is suggested? |
lscorcia
commented
Mar 1, 2022
Thanks for the suggestions! @bartonjs notes make sense and I'd like to give them a shot, it may not look good but I should be able to do it. I also wrote the additional test you mentioned, but despite a few hours spent on it I still have not been able to run it. I always have matching issues between CoreCLR, the libraries and the test assembly. I will spend some more time on it tomorrow. |
lscorcia
commented
Mar 2, 2022
So, I spent way too much time trying to run the This is what I did: When compilation ends, all existing tests fail with the following error: I attached a debugger to the existing test, but at a glance nothing seems off. The error is triggered here, before any network interaction: I verified the parameters and they are correct, I also tried rebasing my code on top of the current main as some things about marshalling have changed but the output is just the same. Can anyone confirm that those tests are actually passing as of today? |
joperezr
commented
Mar 2, 2022
@lscorcia you are right, I'm able to repro the issue. It also seems to repro with other setups as well, as I am seeing this happening with the slapd openldap server as well. Let's open an issue to get that fixed and it is fine if you don't add a functional test on this PR for now, we can add this later as part of the fix of that issue. |
joperezr
commented
Mar 2, 2022
I'm still testing, but is looking like what broke this was #64279 changes cc: @jkoritzinsky |
jkoritzinsky
commented
Mar 2, 2022
Yes, some of the marshalling changes in #64279 affect S.DS.Protocols. Runtime marshalling is disabled in that assembly, so defaults for non-generated P/Invokes are changed. However, I don't think there should be many changes that would affect this particular change in a way that isn't a clear |
joperezr
commented
Mar 3, 2022
@lscorcia the fix for the encoding issue is now checked in. Could you please rebase your PR and try writing your test again? I have validated that the tests pass after following the steps you outlined above. |
lscorcia
commented
Mar 3, 2022
I added the new test which now passes, but I still have to introduce the non-public struct that was suggested above. Shouldn't take too long, will take a look at it tomorrow. Meanwhile, any idea about how to name it? |
lscorcia
commented
Mar 4, 2022
@joperezr I pushed the updated version containing the suggested changes. Test failures seem unrelated. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
lscorcia
commented
Mar 8, 2022
Rebased again to trigger a new test run since the previous one failed due to issues unrelated to this PR. |
lscorcia
commented
Mar 8, 2022
Test failures seem unrelated to this PR. |
joperezr
commented
Mar 9, 2022
I'm sorry that I haven't looked at this yet @lscorcia. I will look at this today. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
joperezr
commented
Mar 16, 2022
@lscorcia thank you so much for addressing all of the comments. One last thing, I'm trying to run your new test against one of the containers we have in our Ldap.Configuration.xml (the slapd with ssl one) and I'm getting an error: Which server did you try your test against? |
joperezr
commented
Mar 16, 2022
Seems like OpenDJ server works just fine. It would be great if we can add a Skip Attribute to your test that ensures SortKey is supported on the target server by looking into the LdapConfiguration index that was set. |
lscorcia
commented
Mar 16, 2022
Yes, I tested it with OpenDJ. In order to use server side sorting with slapd one would have to enable the corresponding overlay (https://www.systutorials.com/docs/linux/man/5-slapo-sssvlv/), and even then in its default schema the uid attribute is not sortable I think. This is a bit overkill for a simple test, so it's probably better to just skip the test if the control is not supported. What I plan to do: add a new element named Is this plan ok for you? |
joperezr
commented
Mar 16, 2022
That sounds perfect. Yeah I wasn't suggesting that you fixed the slapd server so it supported sorting, the only thing I want is that if folks want to manually run the tests against a real server using our Ldap.Configuration.xml provided ones, that they won't see a test failure if they pick slapd one. I'm totally fine with them getting a test skipped if on slapd, and then have it running if they are on opendj |
joperezr
commented
Mar 22, 2022
Merging since failures are unrelated. |
lscorcia
commented
Mar 22, 2022
Thanks for your help and support! 🍻 |
The
SortKeyobjects are marshalled to pointers and then passed to native functions. Under Windows, the native LDAP functions use Unicode strings, while under Linux they use ANSI - this breaks the use of sort controls under Linux. This PR ensures the correct StructLayout CharSet for each platform.Fixes#41618 .