Hello,
Quoting myself from a previous report:
when I started testing parts of musl with TIS Interpreter, I made sure to use TIS Interpreter versions of low-level functions such as memcpy and memset, while testing higher-level functions. Musl's functions can provide guarantees
beyond the standard, and it is fair game to rely on these guarantees elsewhere in musl since musl's versions of these functions are called, but I thought it would be interesting to know that musl provides additional guarantees and relies on them.
An interesting new example just turned up.
musl's implementation of putenv uses memcmp exactly like the blog post says it shouldn't:
However this behavior of musl's memcmp should be documented and preserved in future versions. Otherwise introducing a memcmp optimization in musl similar to Glibc's would silently break putenv, making it segfault in rare and perhaps hard to reproduce
circumstances.
Alternately, it is possible to make putenv rely only on the standard behavior of the functions it calls. It seems to me that strncmp can be used here. The difference in execution speed between memcmp and strncmp should not matter in this context.
Pascal