Hi,I downloaded FilteringNetworkTraffic and added a FilterPacketProvider to intercept network packet with following info.plist:<key>NEProviderClasses</key> <dict> <key>com.apple.networkextension.filter-packet</key> <string>$(PRODUCT_MODULE_NAME).FilterPacketProvider</string> </dict>but the callback function and packetHandler closure do not work at all? thanks!
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
///**************************
// MyClass.m
#import "MyClass.h"
static MyClass *myClass = NULL;
@implementation MyClass
(MyClass *)sharedMyClass {
myClass = NULL;
myClass = [[MyClass alloc] init];
return myClass;
}
@end
Hi Experts, I just want to know myClass is a static ObjC object, it will be automatically released by ARC when no one is referencing it anymore, so no memory leak? is it correct?
Hi Experts,
If multiple NEFilterDataProvider/NEFilterPacketProvider(s) are on the machine and all are active at the same time. which provider will receive the TCP/UDP segment first?
If one of network extension drops the flow or packet, then there is no chance for others to parse it?
which is instantiated first or instantiated last if no earlyboot?
Thanks a lot!
Do I need to Block_release dispatch_block_t which passed to the dispatch_barrier_async when no ARC ?
Do I need to release the block which passed to the dispatchbarrierasync when no ARC ? I noticed "The barrier block to submit to the target dispatch queue. This block is copied and retained until it finishes executing, at which point it is released." in dispatchbarrierasync.dispatch_block_t work = dispatch_block_create(0, ^{
//...
});
if (work) {
dispatchbarrierasync(dispatchQueue, work);
auto res = dispatchblockwait(work, timeout);
if (res) {
// timeout, then cancel, I should release work here?
dispatchblockcancel(work);
}
Blockrelease(work); // do I need to release work when no ARC? the dispatchbarrierasync would release it if it's executed?
}
}
Thanks!
Process: sysextd [633]
Path: /System/Library/Frameworks/SystemExtensions.framework/Versions/A/Helpers/sysextd
Identifier: sysextd
Version: 79.40.4
Code Type: X86-64 (Native)
Parent Process: launchd [1]
Responsible: sysextd [633]
User ID: 0
Date/Time: 2020-11-21 19:06:59.948 +0800
OS Version: macOS 11.0.1 (20B50)
Report Version: 12
Anonymous UUID: E7E0F5B9-898B-B40D-21A3-AF796FC8960A
Time Awake Since Boot: 120 seconds
System Integrity Protection: disabled
Crashed Thread: 1 Dispatch queue: sysextd.extensionmanager
Exception Type: EXCBADINSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXCCORPSENOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [633]
Application Specific Information:
dyld3 mode
Fatal error: 'try!' expression unexpectedly raised an error: sysextd.ExtensionFinishUninstallingAction.actionErrors.outstandingreferences: file sysextd/extensionmanager.swift, line 422
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystemkernel.dylib 0x00007fff203185ce _ulockwait + 10
1 libdispatch.dylib 0x00007fff201a0f98 dlockwait + 44
2 libdispatch.dylib 0x00007fff201a122c dispatchgroupwaitslow + 49
3 libdispatch.dylib 0x00007fff201a3b37 dispatchblockwait + 212
4 sysextd 0x0000000104ff8c3f 0x104ff0000 + 35903
5 sysextd 0x0000000104ffb95f 0x104ff0000 + 47455
6 sysextd 0x0000000104ffb199 0x104ff0000 + 45465
7 libdyld.dylib 0x00007fff20366631 start + 1
Thread 1 Crashed:: Dispatch queue: sysextd.extensionmanager
0 libswiftCore.dylib 0x00007fff2c72f124 assertionFailure(::file:line:flags:) + 532
1 libswiftCore.dylib 0x00007fff2c784629 swiftunexpectedError + 585
2 sysextd 0x0000000105009168 0x104ff0000 + 102760
3 sysextd 0x000000010501047f 0x104ff0000 + 132223
4 sysextd 0x0000000105012018 0x104ff0000 + 139288
5 sysextd 0x0000000104ff8c86 0x104ff0000 + 35974
6 libdispatch.dylib 0x00007fff201ad1d5 dispatchblockasyncinvoke2 + 83
7 libdispatch.dylib 0x00007fff201a07c7 dispatchclientcallout + 8
8 libdispatch.dylib 0x00007fff201a65fe dispatchlaneserialdrain + 606
9 libdispatch.dylib 0x00007fff201a70cb dispatchlaneinvoke + 375
10 libdispatch.dylib 0x00007fff201b0c5d dispatchworkloopworkerthread + 819
11 libsystempthread.dylib 0x00007fff20348499 pthreadwqthread + 314
12 libsystempthread.dylib 0x00007fff20347467 startwqthread + 15
Thread 1 crashed with X86 Thread State (64-bit):
rax: 0x0000000200000003 rbx: 0x0000000105066360 rcx: 0xfffffffe00000000 rdx: 0x0000000000000003
rdi: 0x00007fd5ddd06f08 rsi: 0x00000000000bcfa0 rbp: 0x00007000082ed2f0 rsp: 0x00007000082ed2a0
r8: 0x0000000000000110 r9: 0x000000000000001b r10: 0x00007fd5ddc00000 r11: 0x0000000000000000
r12: 0x0000000000000000 r13: 0x000000000000000b r14: 0x0000000000000001 r15: 0x00007fff2cab8944
rip: 0x00007fff2c72f124 rfl: 0x0000000000010246 cr2: 0x00007fff80068470
Logical CPU: 0
Error Code: 0x00000000
Trap Number: 6
Thread 1 instruction stream:
41 0f b6 c7 48 89 03 49-c7 46 10 01 00 00 00 41 A...H..I.F.....A
bf 01 00 00 00 48 8b 7d-d0 e9 19 01 00 00 48 89 .....H.}......H.
4d c0 4c 89 65 c8 4c 89-e7 41 89 f4 e8 5b 8a 34 M.L.e.L..A...[.4
00 41 0f b6 cc 48 8d 7d-c0 48 89 de 48 8b 55 10 .A...H.}.H..H.U.
4d 89 f8 4d 89 e9 45 31-e4 41 56 ff 75 20 e8 29 M..M..E1.AV.u .)
18 00 00 48 83 c4 10 48-8b 7d c8 e8 cc 8a 34 00 ...H...H.}....4.
[0f]0b 44 89 f9 c1 e9 06-44 89 f8 83 e0 3f c1 e0 ..D.....D....?.. <==
08 41 81 ff 00 08 00 00-73 0d 09 c8 ba c1 81 00 .A......s.......
00 48 8b 7d d0 eb 38 83-e1 3f 09 c8 44 89 f9 c1 .H.}..8..?..D...
e9 0c c1 e0 08 41 81 ff-ff ff 00 00 48 8b 7d d0 .....A......H.}.
77 09 09 c8 ba e1 81 81-00 eb 14 83 e1 3f 09 c8 w............?..
41 c1 ef 12 c1 e0 08 44-09 f8 ba f1 81 81 81 8d A......D........
Thread 1 last branch register state not available.
Binary Images:
0x104ff0000 - 0x105073fff sysextd (79.40.4) <4ED43E22-4E63-3CA2-9354-AB354CE49D62> /System/Library/Frameworks/SystemExtensions.framework/Versions/A/Helpers/sysextd
Hi Experts,
How to use a variable in @available(macOS ver, *), I do not want to hard code like this:
if (@available(macOS 10.16, *))
{
//...
}
Thanks a lot!
Hi Experts,
I knew there is LSEnvironment for defining environment variables to be set before launching.
e.g.
<key>LSEnvironment</key>
<dict>
<key>PATH</key>
<string>/Users/flori/.rvm/gems/ruby-1.9.3-p362/bin:/Users/flori/.rvm/gems/ruby-1.9.3-p362@global/bin:/Users/flori/.rvm/rubies/ruby-1.9.3-p326/bin:/Users/flori/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:</string>
</dict>
How about system extension? Thanks a lot.
Topic:
App & System Services
SubTopic:
Drivers
Tags:
System Extensions
Endpoint Security
Network Extension
Hi Experts,
I knew there is LSEnvironment for defining environment variables to be set before launching App.
e.g.
<key>LSEnvironment</key>
<dict>
<key>PATH</key>
<string>/Users/flori/.rvm/gems/ruby-1.9.3-p362/bin:/Users/flori/.rvm/gems/ruby-1.9.3-p362@global/bin:/Users/flori/.rvm/rubies/ruby-1.9.3-p326/bin:/Users/flori/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:</string>
</dict>
How about system extension? How can I set some environment variables before running? Thanks a lot.
Topic:
App & System Services
SubTopic:
Core OS
Tags:
macOS
Extensions
System Extensions
Network Extension
I ran a test code with ThreadSanitizer, it throws a race condition in the block of xpcconnectionseteventhandler even I set a sync queue to the connection. xpc_connection_set_event_handler(conn, ^(xpc_object_t event) {
xpc_type_t type = xpc_get_type(event);
if (xpc_get_type(event) == XPC_TYPE_DICTIONARY) {
		// race condition here
		// WARNING: ThreadSanitizer: data race
// ...
} else {
if (event == XPCERRORCONNECTIONINVALID) {
// Error indicates the peer has closed the connection.
// Tear down any associated data structures.
} else {
// Error indicates that service will terminate soon.
// Flush all buffers, finish all work, etc.
}
xpcrelease(peer);
}
});
https://developer.apple.com/documentation/xpc/1448786-xpc_connection_set_target_queue?language=objc:
"the XPC runtime guarantees that, when the target queue is a serial queue, the event handler block will execute synchronously with respect to other blocks submitted to that same queue. When the target queue is a concurrent queue, the event handler block may run concurrently with other blocks submitted to that queue, but it will never run concurrently with other invocations of itself for the same connection"
looks like there should have no race condition according to the above description, but why I encounter the race condition issue reported by ThreadSanitizer?
Does the block of xpcconnectionseteventhandler need sync to avoid race condition?
NEFilterManager * mgr = [NEFilterManager sharedManager];
...
NSString *description = [mgr localizedDescription]
Hi Experts,
I can get another NEFilterManager instance if there are multi-network profilers in the Network panel.
The above code is in a different background process(bundle id) than the main process without any entitlement. I can only get the correct NEFilterManager instance associated with the main process, is it by design? how to get a specified NEFilterManager instance in the background process?
Hi Expert,
I found the value of kDADiskDescriptionVolumeUUIDKey changed after upgrading to BigSur from Catalina, so it should not be used to identify a unique machine?
Btw: I found there is another unique hardware UUID in "system_profiler SPHardwareDataType"
Hi Expert,
When I launched my App, just saw the following crash once:
crash log
Looks like there is something dead loop in the system libraries? related to NSNotificationCenter? any clue on this? Thanks a lot.
Hi Experts,
Looks like es_mute_path_xxx are deprecated, so does anyone know if there has some new APIs? Thanks!
https://developer.apple.com/documentation/endpointsecurity/3366123-es_mute_path_prefix
Hi Experts,
I created a simple application with the following code to retrieve the signing info from Apps such as Xcode:
CFURLRef appURLRef = NULL;
SecStaticCodeRef staticCodeRef = NULL;
CFDictionaryRef signatureInfoRef = NULL;
do {
appURLRef = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR("/Applications/Xcode.app"), kCFURLPOSIXPathStyle, YES);
if(!appURLRef) {
break;
}
OSStatus status = SecStaticCodeCreateWithPath(appURLRef, kSecCSDefaultFlags, &staticCodeRef);
if(errSecSuccess != status) {
break;
}
status = SecCodeCopySigningInformation(staticCodeRef, kSecCSSigningInformation, &signatureInfoRef);
if(errSecSuccess != status) {
break;
}
} while(0);
if(staticCodeRef) {
CFRelease(staticCodeRef);
staticCodeRef = NULL;
}
if(signatureInfoRef) {
CFRelease(signatureInfoRef);
signatureInfoRef = NULL;
}
if(appURLRef) {
CFRelease(appURLRef);
appURLRef = NULL;
}
then I use leaks to check if any memory issues, the output is:
Process: checksig [4733]
Path: /Users/USER/Library/Developer/Xcode/DerivedData/Build/Products/Debug/checksig
Load Address: 0x10e033000
Identifier: checksig
Version: ???
Code Type: X86-64
Platform: macOS
Parent Process: leaks [4732]
Date/Time: 2022-02-13 23:10:32.606 +0800
Launch Time: 2022-02-13 23:10:32.109 +0800
OS Version: Mac OS X 10.15.6 (19G73)
Report Version: 7
Analysis Tool: /Applications/Xcode.app/Contents/Developer/usr/bin/leaks
Analysis Tool Version: Xcode 12.4 (12D4e)
----
leaks Report Version: 4.0
Process 4733: 3725 nodes malloced for 456 KB
Process 4733: 1 leak for 32 total leaked bytes.
1 (32 bytes) ROOT LEAK: 0x7ffc33d04c00 [32] length: 23 ",CSSMERR_CL_UNKNOWN_TAG"
If I remove the SecCodeCopySigningInformation line, then the issue is gone.
So there is a memory leak in API SecCodeCopySigningInformation? or in my code or sth incorrect in the report of leaks?
Did anybody see the same issue before? thanks a lot!
Hi @eskimo and experts,
I created a simple code and found there is a memory leak:
#import <Foundation/Foundation.h>
#include <functional>
void testLeaks(const std::function <void (int)>& inCallback) {
NSTask* task = [[NSTask alloc] init];
[task setTerminationHandler:^(NSTask* inTask) {
inCallback(inTask.terminationStatus);
}];
[task release];
}
int main(int argc, const char * argv[]) {
auto callback = [](int result) {
NSLog(@"callback");
};
testLeaks(callback);
NSLog(@"done");
return 0;
}
The output of leaks:
Process: testLeaks2 [13084]
Path: /Users/USER/Library/Developer/Xcode/DerivedData/Build/Products/Debug/testLeaks2
Load Address: 0x10a04d000
Identifier: testLeaks2
Version: ???
Code Type: X86-64
Platform: macOS
Parent Process: leaks [13083]
Date/Time: 2022-02-28 23:34:28.374 +0800
Launch Time: 2022-02-28 23:34:27.939 +0800
OS Version: Mac OS X 10.15.6 (19G73)
Report Version: 7
Analysis Tool: /Applications/Xcode.app/Contents/Developer/usr/bin/leaks
Analysis Tool Version: Xcode 12.4 (12D4e)
----
leaks Report Version: 4.0
Process 13084: 596 nodes malloced for 59 KB
Process 13084: 1 leak for 48 total leaked bytes.
1 (48 bytes) ROOT LEAK: <__NSMallocBlock__ 0x7fbbc2704350> [48] testLeaks2 invocation function for block in testLeaks(std::__1::function<void (int)> const&) 0..."
Looks the issue is in the block of setTerminationHandler. How do I address this memory leak issue if I want to keep using std::function as a callback?