mailing list of musl libc
 help / color / mirror / code / Atom feed
* bug? sysinfo() and getopt_long() misbehavior
@ 2012-06-07 16:51 orc
  2012-06-08  3:12 ` Rich Felker
  0 siblings, 1 reply; 8+ messages in thread
From: orc @ 2012-06-07 16:51 UTC (permalink / raw)
  To: musl; +Cc: Rich Felker

I have built a musl-enabled system and encountered some bugs:

- sysinfo() incorrectly works. The result is busybox' free misbehaving:
% ./busybox free -m
             total         used         free       shared      buffers
Mem:           476          476            0          183        10489
-/+ buffers:      17592186034402        10489
Swap:        10135        10135            0

gdb shows garbage in struct after free calls sysinfo() with musl.

Reproducible with:
% cat procs.c 
#include <stdio.h>
#include <sys/sysinfo.h>

int main(void)
{
	struct sysinfo info;

	if(sysinfo(&info) == 0)
		printf("procs: %d\n", info.procs);
	return 0;
}
% gcc procs.c # glibc
% ./a.out
procs: 120
% musl-gcc procs.c # musl
% ./a.out
procs: -149225472

- (did not investigated properly) possible getopt_long() misbehavior, or
  just miscompile. The result is that iptables and gnu sed misbehaving
  at command line arguments:
% sed -i '/test/d' ttnosuchfile
sed: can't find label for jump to `tnosuchfile'
% sed '/test/d' -i ttnosuchfile
sed: can't read -i: No such file or directory
sed: can't read ttnosuchfile: No such file or directory
# iptables -vnL
iptables v1.4.12.1: unknown arguments found on commandline
Try `iptables -h' or 'iptables --help' for more information.
# iptables --version
iptables v1.4.12.1: unknown arguments found on commandline
Try `iptables -h' or 'iptables --help' for more information.

Both sed and iptables were compiled with -D_GNU_SOURCE defined.

Unfortunately I don't actually know how to fix these two.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-07-01 10:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-07 16:51 bug? sysinfo() and getopt_long() misbehavior orc
2012-06-08  3:12 ` Rich Felker
2012-06-08  5:27   ` orc
2012-06-08 12:12     ` orc
2012-06-08 14:12       ` Rich Felker
2012-07-01 10:20         ` orc
2012-06-08  5:37   ` Isaac Dunham
2012-06-08 14:10     ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).