On 10/3/21 4:59 AM, 小太 wrote:
On Sun, 3 Oct 2021 at 20:47, Ryan Thoryk <r...@thoryk.com> wrote:
"Bad permissions for mapped region at address" can also mean it tried
to read from unreadable memory. The memory was mapped at some
point in the past, so it doesn't say unallocated memory

Also consider the segfault comes from strcmp(). Why would strcmp()
ever need to write to memory? You can verify with a disassember the
segfault comes from a read

The strcmp stumped me too. I assumed it was trying to copy from a null pointer, but valgrind shows that the address wasn't null. I forgot about the strcmp detail when writing my comment, strcmp is read-only.


I suspect this "worked" to fix the issue only due to a memory layout
change, and luck would have it that after your rebuild it now tries to
read from readable memory (albeit still not the expected memory)


After looking over the glib docs, the function does a const on the string, so it shouldn't be able to do a write.

I don't know enough about handling C-strings (I've mostly done C++ strings), but the only difference is the location of stored memory, maybe it's getting an access error when trying to access the literal (since it's being done from an external library), as opposed to a stack allocation. That's the only thing I can think of. Valgrind doesn't show any warning or error using this method, so it appears to be fine. I'll bring this up on the glibmm upstream and see what they say. I think the proper way to to define it is "static const char[]" instead of "char[]", but it might not matter that much.

--
Ryan Thoryk
r...@thoryk.com
r...@tliquest.net

Reply via email to