-
Notifications
You must be signed in to change notification settings - Fork 6
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
Crash in malloc while allocating logger name. #6
Comments
Hmm, digging into the code a bit, I'm wondering if this is the problem: let subsystem = to_cstr(subsystem);
let category = to_cstr(category);
let inner = unsafe { os_log_create(subsystem.as_ptr(), category.as_ptr()) }; Depending on what I will try giving |
…ers to the OS's logging subsystem, which may attempt to use them after they have been dropped. The fix simply adds the CStrings as fields to the logger instance, so they are guaraneteed to be retained for the lifetime of the logger.
That does indeed eliminate the crashes - I had one project which would crash in the way described very frequently, which now runs without any problem. |
I'm attempting to use
os_log
in some AudioUnit system extensions. Intermittently, logging initialization will crash hard while attemping to allocate the c-string for the logger name (!).I'm not sure if there are some restrictions on allocating memory during initialization of a system extension, but it seems pretty odd (any chance the C-string you're translating the passed logger name into could accidentally be set to an extremely large size?).
For that matter, since in my case, since it's perfectly possible for me to allocate the logger name as a
const
c-string, it would be nice to be able to pass in c-string and avoid the allocation entirely - though while that might bypass this issue, it seems like something is probably genuinely wrong here.The text was updated successfully, but these errors were encountered: