boostorg / boostorg/system

getting crash on writing to readonly memory region while generating ec for exception

Open
#99 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
45
Forks
96
PR merge metrics
No merged PRs in 30d

Description

I'm trying to figure out a crash dump that I got when initiating a boost implementation of unix domain socket.

What's strange about it is that the relevant frame is when it parsed the ec.what() which is a function that basically create a string message ...

```
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 P 0x104919660 boost::system::error_code::what() const (in P_arm64.dsym) + 528 + 251488
1 P 0x104919654 boost::system::error_code::what() const (in P_arm64.dsym) + 516 + 251476
2 P 0x104918ea8 boost::system::system_error::system_error(boost::system::error_code const&, char const*) (in P_arm64.dsym) + 308 + 249512
3 P 0x104adbd10 boost::asio::basic_socket::connect(boost::asio::local::basic_endpoint const&) (in P_arm64.dsym) + 1808 + 2096400
(--> this is my c'tor that initiate the unix domain socket)
4 P 0x104ad9ed4 service::api::Instance(std::__1::function __DATA_CONST 107006000-10705e000 [ 352K] r--/rw- SM=COW ...s/MacOS/P
__DATA 10705e000-107072000 [ 80K] rw-/rw- SM=COW ...s/MacOS/P
```

So It seems like when the ec message is created, we attempt to write a read only memory (DATA_CONST) . I think that this is the problematic code :
```

source_location const & location() const BOOST_NOEXCEPT
{
BOOST_STATIC_CONSTEXPR source_location loc;
return lc_flags_ >= 4? *reinterpret_cast( lc_flags_ &~ static_cast( 1 ) ): loc;
}

```
which is called from here

```
std::string what() const
{
std::string r = message();
r += " [";
r += to_string();
if( has_location() )
{
r += " at ";
--> r += location().to_string();
}

r += "]";
return r;
}

```
However, i don't understand where do we attempt to write to the const expression 'loc'... any idea what may be the reason ?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.