Skip to content

Strange conflict between NSProcessInfo and NSScreen, causing segmentation fault. #107

Description

@wspl

I found a strange conflict issue between NSScreen and NSProcessInfo. Using both NSProcessInfo.operatingSystemVersion and UIScreen.mainScreen will cause the application to crash with "segmentation fault". But I can't imagine the relation between them.

Minimal Example:

#[macro_use]
extern crate objc;

use cocoa::{appkit::NSScreen, base::nil};
use objc::{runtime::Object};

fn main() {
    unsafe {
        let ns_process_info = class!(NSProcessInfo);
        let process_info: *mut Object = msg_send![ns_process_info, processInfo];
        // Deleting either of the following two lines will avoid the crash.
        let os_version: *const Object = msg_send![process_info, operatingSystemVersion];
        let screen = NSScreen::mainScreen(nil);
    }
}
[package]
name = "rsplg"
version = "0.1.0"
edition = "2018"

[dependencies]
cocoa = "0.24"
objc = "0.2.7"
objc-foundation = "0.1"

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