Skip to content

_uselocale() overwrites data over a variable allocated near 0 #4423

Closed
@shooshx

Description

@shooshx

In my main cpp file I have a global variable g_ctrl which for some reason is allocated near the very beginning of the memory array. printing its address using

 printf("GCTRL  %p\n", &g_ctrl)

shows

GCTRL 0x40

Other global variables are not allocated such low addresses, only this one, I'm not sure why.
At some point pretty early in the program _uselocale() from some operator<< This function does _pthread_self() which returns 0 always, adds 176 to it and stores some value there. 0+176 just happens to fall on the capacity member of some std::vector in g_ctrl and from there it just goes downhill.

This is probably not relevant but I started noticing this only after compiling with -D_LIBCPP_DEBUG=0 which probably changed the layout of my objects abit and caused this to start happening. g_ctrl is allocated a low address even without _LIBCPP_DEBUG=0

I'm using 1.35.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions