You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NSData.dataWithBytesNoCopy_length_ is crashing #1107
ns_data_test.dart causes some sort of seg faults crash loop when using NSData.dataWithBytesNoCopy_length_. I'm switching to NSData.dataWithBytes_length_ for now, which fixes the crash but is slower. Logs.
I noticed the crash in #1100, but it predates that PR (that log is from a nightly run). I haven't been able to get GDB working on my macbook, so I'm not sure exactly where the crash is happening. From the logs it seems to be happening when the NSData is destroyed.
I'm not sure how this fits together. Presumably the malloc of the current process could mean tcmalloc or jemalloc, depending on how the application is linked? But I'd guess that NSData uses whatever the standard deallocator is? Or maybe not ;-)
I think that this code is probably OK how it is now. If people complain about the performance when using large blocks of memory, we could use initWithBytesNoCopy:length:deallocator:
Activity
brianquinlan commentedon Apr 29, 2024
@dcharkes
NSData dataWithBytesNoCopy:length:freeWhenDone:takes ownership of a block of memory that was allocated withmalloc.Is the
package:ffi mallocthe (presumably)libcmallocthatNSDataexpects?dcharkes commentedon May 1, 2024
LLDB is the Mac variant.
native/pkgs/ffi/lib/src/allocation.dart
Lines 15 to 16 in 6a9282c
Yep, it's
mallocin the current process.brianquinlan commentedon May 1, 2024
I'm not sure how this fits together. Presumably the
mallocof the current process could meantcmallocorjemalloc, depending on how the application is linked? But I'd guess thatNSDatauses whatever the standard deallocator is? Or maybe not ;-)Apple's documentation isn't very clear on this. I also notice that we don't use
NSData dataWithBytesNoCopy:length:freeWhenDone:at Google at all.I think that this code is probably OK how it is now. If people complain about the performance when using large blocks of memory, we could use
initWithBytesNoCopy:length:deallocator:vaind commentedon Jul 2, 2024
From the docs:
brianquinlan commentedon Jun 26, 2025
I think that we can close this?