[llvm-bugs] [Bug 46399] New: __NSStackBlock__ cant't be copy to __NSMallocBlock__ in arc

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 19 06:36:27 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46399

            Bug ID: 46399
           Summary: __NSStackBlock__ cant't be copy to __NSMallocBlock__
                    in arc
           Product: clang
           Version: trunk
          Hardware: Other
                OS: other
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sunbohong at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

The follow code will be crash in iOS.

-(NSArray*)getBlockArray
{
  int num = 916;
  return [NSArray arrayWithObjects:
          ^{ NSLog(@"this is block 0:%i", num); },
          ^{ NSLog(@"this is block 1:%i", num); },
          ^{ NSLog(@"this is block 2:%i", num); },
          nil];
}

- (void)forTest
{
  int a = 10;
  int b = 20;
}

- (void)test
{
  NSArray*  blockArr = [self getBlockArray];
  [self forTest];

  void (^blockObject)(void);
  for(blockObject in blockArr){
    blockObject();
}

===================
And the follow code will print blocks with different type in macOS.

void testBlockArray() {
  int val = 10;
  NSArray *arr = [NSArray arrayWithObjects:^(){NSLog(@"blk0:%d",
val);},^(){NSLog(@"blk1:%d", val);}, nil];
  NSLog(@"%@", arr);

}

(
    "<__NSMallocBlock__: 0x600003bb6e80>",
    "<__NSStackBlock__: 0x7ffedfdf7c10>"
)


==================

I try to fix this crash with
https://github.com/sunbohong/llvm-project/commit/7132d1ee82431ee182775cc65d5de1091cb78cde

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200619/703a224a/attachment.html>


More information about the llvm-bugs mailing list