Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
This repository was 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

Description

@huuang

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions