Changes between Initial Version and Version 1 of Ticket #68028, comment 6


Ignore:
Timestamp:
Nov 4, 2023, 11:02:55 PM (11 months ago)
Author:
erikbs
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #68028, comment 6

    initial v1  
    1414}}}
    1515
    16 Running `lldb` I get an `EXC_BAD_ACCESS` stop with code 2, which is `KERN_PROTECTION_FAILURE`, i.e. stack buffer overflow, the same as comment:ticket:68015:2. The backtrace, being 23 frames long, reveals that there is no infinite recursion. In frame 0 the value of the RSP register is 0x00007fff5fb80238, while in frame 23 it is 0x00007fff5fbff8d8. The difference is `521 888`, but, if I have understood things correctly, since RSP holds the return address, this number only tells us the approximate stack size. The instruction that fails is `0x1000cc8ee:  movq   $0x0, (%rsp)`. From this I would guess that the stack size is 512 kiB? And that the instruction at 0x1000cc8ee writes to an address that causes stack buffer overflow with a stack size of 512 kiB? However, according to the Rust docs, [https://doc.rust-lang.org/std/thread/#stack-size the default stack size on “Tier-1 platforms” is 2 MiB]. `x86_64-apple-darwin` is a “Tier-1 platform”, but the notes say 10.12+. Maybe it somehow is still set to 512 kiB, I have no idea, but with that in mind I wanted to try to set the stack size to 2 MiB explicitly during linking. Just to have it mentioned, `ulimit -s` reports a stack size limit of 8192 (8 MiB).
     16Running `lldb` I get an `EXC_BAD_ACCESS` stop with code 2, which is `KERN_PROTECTION_FAILURE`, i.e. stack buffer overflow, the same as comment:ticket:68015:2. The backtrace, being 23 frames long, reveals that there is no infinite recursion. In frame 0 the value of the RSP register is 0x00007fff5fb80238, while in frame 23 it is 0x00007fff5fbff8d8. The difference is `521 888`, but, if I have understood things correctly, since RSP holds the return address, this number only tells us the approximate stack size. The instruction that fails is `0x1000cc8ee:  movq   $0x0, (%rsp)`. From this I would guess that the stack size is 512 kiB? And that the instruction at 0x1000cc8ee writes to an address that causes stack buffer overflow with a stack size of 512 kiB? However, according to the Rust docs, [https://doc.rust-lang.org/std/thread/#stack-size the default stack size on “Tier-1 platforms” is 2 MiB]. `x86_64-apple-darwin` is a “Tier-1 platform”, but the notes say 10.12+. Maybe it somehow is still set to 512 kiB, I have no idea, but with that in mind I wanted to try to set the stack size to 2 MiB explicitly during linking ([https://www.dsfcode.com/posts/increase-rust-stack-size-on-macos/ helpful resource]). Just to have it mentioned, `ulimit -s` reports a stack size limit of 8192 (8 MiB).
    1717
    1818Just to make sure that I am on the right track, I compiled the following simple C++ program (stack.cpp):