blob: 490f6aa6e5d028f62540951d4c38e58b5c6bc8d5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
C++ iostreams cause a segmentation fault
Inserting into std::cout or std::cerr causes a segmentation fault. The following program segfaults when compiled for x86_64 using either gcc 12.1.0 or clang 13.0.1 and run under box64 on both AArch64 and x86_64:
```
#include <iostream>
int main(int argc, char* argv[]) {
std::cout << "broken\n";
return 0;
}
```
```
6407|SIGSEGV @0x64941284 (???(box64+0x64941284)) (x64pc=0x7feadb4a05fe/libstdc++.so.6:"libstdc++.so.6/_ZNSo6sentryC2ERSo + 30", rsp=0x7feadad7c450), for accessing 0xffffffffffffffe8 (code=1)
```
Comparing the trace with native execution, it appears that at the time of the segfault, RSI contains the address of std::cout, but there are two addresses at std::cout when executed natively and a bunch of zeroes at std::cout under box64, so RAX gets loaded with a null pointer.
printf does not suffer from this issue.
|