Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

MACH_Exception EXC_BAD_INSTRUCTION EXC_ARM_UNDEFINED fault_address:0x0000000108460684 #576

Open
huuang opened this issue Dec 16, 2021 · 0 comments

Comments

@huuang
Copy link

huuang commented Dec 16, 2021

Had a EXC_BAD_INSTRUCTION EXC_ARM_UNDEFINED issue on code -[GCDWebServer(Extensions) startWithPort:bonjourName:](GCDWebServer.m:828) when I created a GCDWebServer instance and started it in a dispatch_once block. Below is my code, any ideas will be appreciated.

@interface HttpServerManager()

@property (nonatomic, strong) GCDWebServer *webServer;
@property (nonatomic, assign) UInt16 port;

@end

@implementation HttpServerManager

+ (instancetype)sharedInstance
{
    static HttpServerManager *instance;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        instance = [HttpServerManager new];
        [GCDWebServer setLogLevel: 3];
    });
    return instance;
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        _webServer = [GCDWebServer new];
        [_webServer addHandlerWithMatchBlock: ^GCDWebServerRequest * _Nullable(NSString * _Nonnull requestMethod, NSURL * _Nonnull requestURL, NSDictionary<NSString *,NSString *> * _Nonnull requestHeaders, NSString * _Nonnull urlPath, NSDictionary<NSString *,NSString *> * _Nonnull urlQuery) {
            return [[GCDWebServerDataRequest alloc] initWithMethod: requestMethod url: requestURL headers: requestHeaders path: urlPath query: urlQuery];
        } asyncProcessBlock: [self asyncProcessBlock]];
        [self startServer];
    }
    return self;
}

- (void)startServer
{
    if (self.webServer.isRunning == NO) {
        BOOL success = NO;
        for (int port = 8190; port < 8290; port++) {
            success = [self.webServer startWithPort: port bonjourName: nil];
            if (success) {
                self.port = port;
                break;
            }
        }
    }
}

@end
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant