Repository navigation
Conversation
a0cd7ae to
9f353a3
Compare
|
The failing job "Windows arm64 MSVC Clang gnustep-2.2" is not caused by this change. It fails on master with the same test and message: basic.m:54 ... call stack addresses is not empty (one failed test in each run).
This PR only touches Source/NSConnection.m and adds Tests/base/NSConnection/bycopyReturn.m. |
A method declared to return (bycopy NSArray *) still sent its result back over a connection as a proxy. The server side encoded the return value with -encodeValueOfObjCType:at: and ignored the qualifier, while arguments already went through -encodeBycopyObject: and -encodeByrefObject:. The caller then paid one round trip for every message to the result, and fast enumeration of it crashed, because -countByEnumeratingWithState:objects:count: cannot pass its C array over the connection. The returned object is now encoded with -encodeBycopyObject: or -encodeByrefObject: when the method's return type carries the qualifier, in the same way as for arguments. Unqualified return values are encoded as before. Tests/base/NSConnection/bycopyReturn.m checks all three cases over a pair of local ports.
9f353a3 to
be6cb2c
Compare
|
The GCC job aborts of Tests/base/NSTask/posix_spawn_multithread.m (Ubuntu x64 GCC https://github.com/gnustep/libs-base/actions/runs/46129340154/job/140930868162 and GCC-4.9.4 https://github.com/gnustep/libs-base/actions/runs/46132795847/job/140941455958) are an intermittent hang in NSTask that does not depend on this change. The same jobs passed on the other runs of this branch, and the test does not use NSConnection. I ran that test binary 120 times (6 in parallel, 40 second limit) against a libgnustep-base built from master (this PR's Source/NSConnection.m change reverted) and 120 times against one built with this PR. Both built the same way (same tree, only NSConnection.m differs, local Linux build, not GCC).
gdb on the hung master process shows thread 2 in -[TaskRunner runTask:] -> -[NSTask waitUntilExit] (NSTask.m:896) -> -[NSRunLoop runMode:beforeDate:] -> poll(), and the main thread in main() at posix_spawn_multithread.m:130 spinning the run loop. No NSConnection code is on either stack. |
|
This fix is obviously correct, and the fast enumeration issue is important, and the change really looks to be safe, but I think it's just too late to be included in the next release. We should do a bug fix release in January with it. |
|
PS the info about NSTask is really interesting. A Google search reveals a lot of people have similar issues with Apple's implementation not working properly when you wait for task exit outside the main thread too. I have some ideas about fixing that, but again that's not something we can address right now. |
A method declared to return
(bycopy NSArray *)still sends its result back over a connection as a proxy:-[NSConnection _service_forwardForProxy:]encodes the return value with-encodeValueOfObjCType:at:and drops the qualifier, while arguments already go through-encodeBycopyObject:/-encodeByrefObject:(cifframe_dissect_call()). The caller then pays one round trip per message to the result, and afor ... inloop over it crashes, because-countByEnumeratingWithState:objects:count:cannot pass its C array over the connection.Reproducer (server and client in one process, two local ports):
The change encodes a returned object with
-encodeBycopyObject:or-encodeByrefObject:when the return type carries the qualifier, as is done for arguments; unqualified return values are encoded as before. The new testTests/base/NSConnection/bycopyReturn.mchecks bycopy, byref and unqualified returns:cc @pkgdemon