-
Notifications
You must be signed in to change notification settings - Fork 285
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
Add CI leg for msys2/mingw64 using libobjc2 + gnustep-2.0 ABI #374
Conversation
The relevant test failures:
and
I assume both are related to #373, let me cherry-pick that into this PR |
Both test failures seem to |
I vaguely remember having seen something like that happen with libobjc2 long ago, and I think David said it was to do with mixing C++ and ObjC exceptions somehow, but I don't recall any details. |
a32c9dc
to
99af912
Compare
Looks like this is specific to an exception being caught in @davidchisnall Any idea? |
There were some LLVM issues with that structure in SEH, but they were fixed. Maybe the fix doesn’t work for MinGW’s weird hybrid? If you can make the same shape work with C++ but fail with ObjC, we can compare the code and see. |
It looks somewhat similar to this: https://lists.gnu.org/archive/html/discuss-gnustep/2017-12/msg00083.html / https://lists.gnu.org/archive/html/discuss-gnustep/2017-12/msg00110.html:
I'll try create a simple program which can reproduce the issue. Meanwhile, 99af912 seems to be a workaround, perhaps that provides some additional insight? |
Just leaving some notes here: This issue looks very similar to the issue which was reported in 2017. The small repro can be used to reproduce the issue, and re-throwing the exception out of the @catch block fixes the issue -- see test code below. Looks like the original fix was gnustep/libobjc2@7bd78e5. There was a repo in libobjc2 (gnustep/libobjc2#50), but not sure that test is still part of the test suite. I'll try to look into that later. // Build dependencies:
// pacman -S mingw-w64-x86_64-gnustep-base mingw-w64-x86_64-gnustep-make mingw-w64-x86_64-clang mingw-w64-x86_64-lld
//
// Compile with:
// clang $(gnustep-config --objc-flags) $(gnustep-config --base-libs) repo.m
#import <Foundation/Foundation.h>
@interface MinRep2 : NSObject {
}
- (void)poke;
@end
@implementation MinRep2
- (void)poke {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NS_DURING {
[NSException raise:@"foo" format:@"bar"];
} NS_HANDLER {
[localException retain];
[pool release];
[[localException autorelease] raise];
} NS_ENDHANDLER
[pool release];
}
- (void)poke2 {
NSException* caughtException = nil;
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NS_DURING {
[NSException raise:@"foo" format:@"bar"];
} NS_HANDLER {
[localException retain];
[pool release];
caughtException = localException;
// [[localException autorelease] raise];
} NS_ENDHANDLER
[pool release];
[caughtException raise];
}
@end
int main()
{
id obj = [MinRep2 new];
@try
{
[obj poke2];
}
@catch (NSException * localException)
{
fprintf(stderr, "[obj poke2]: Caught an exception.\n");
}
@try
{
[obj poke];
}
@catch (NSException * localException)
{
fprintf(stderr, "[obj poke]: Caught an exception.\n");
}
} |
That's unlikely to be the cause, since on MinGW we don't hit any of those code paths: we just pretend that we're throwing C++ exceptions all of the time. |
@davidchisnall I've verified locally that this is because the vectored exception handler which is used on mingw64 gets invoked for (certain?) exceptions which would be caught by the normal application flow. This results in I wasn't able to find a way within I've opened https://github.com/gnustep/libobjc2/pull/278/files to remove the vectored exception handler from libobjc2 on mingw64. |
99af912
to
d609147
Compare
@rfm This was fixed via gnustep/libobjc2#278, which has been backported to the version of libobjc2 which is in MinGW. The remaining CI failure is, I believe, unrelated and being tracked by #367. So - I think this is good to go. Really cool to see all libs-base tests passing on MinGW/libobjc2/clang, thanks @davidchisnall for your patience with me during the process. |
libobjc2 now supports msys2/mingw64 and is part of the msys2 package repositories, so it's easier to add a CI job which uses that environment.
I had to make one minor change in
Tests/GNUMakefile
to avoid passing a-rpath
flag on mingw.The check for thread-safe +initialize in runtime will fail, but I believe #373 fixes that.