Bug 84652

Summary: kbdmap -r dumps core
Product: Base System Reporter: Andreas Eder <andreas_eder>
Component: amd64Assignee: freebsd-amd64 (Nobody) <amd64>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.4-STABLE   
Hardware: Any   
OS: Any   

Description Andreas Eder 2005-08-07 19:30:21 UTC
kbdmap -r gets a segmentation fault and dumps core

gdb /usr/sbin/kbdmap kbdmap.core prints out
Core was generated by `kbdmap'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libc.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.5
Reading symbols from /libexec/ld-elf.so.1...(no debugging symbols found)...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x00000008006e0fb3 in strdup () from /lib/libc.so.5

How-To-Repeat: simply repeat the program invocation
Comment 1 Vasil Dimov 2005-10-10 13:35:00 UTC
This problem is not amd64 specific,
instead it should be in the `bin' category.

parse_args() uses font_current before it is initialized.

--- kbdmap.c-r.diff begins here ---
--- usr.sbin/kbdmap/kbdmap.c.orig	Mon Oct 10 15:13:05 2005
+++ usr.sbin/kbdmap/kbdmap.c	Mon Oct 10 15:11:50 2005
@@ -823,12 +823,12 @@
 
 	program = extract_name(argv[0]);
 
-	/* Parse command line arguments */
-	parse_args(argc, argv);
-
 	font_current = get_font();
 	if (font_current == NULL)
 		font_current = font_default;
+
+	/* Parse command line arguments */
+	parse_args(argc, argv);
 
 	if (strcmp(program, "kbdmap"))
 		dir = fontdir;
--- kbdmap.c-r.diff ends here ---
Comment 2 Devon H. O'Dell 2005-11-05 04:40:42 UTC
I have the same issue in -CURRENT/amd64 and it is indeed not specific to
the amd64 architecture. The patch attached by Vasil Dimov fixes the
issue for me. The bug should be refiled under bin and the patch supplied
by Vasil works fine and should be applied :)

--Devon
Comment 3 Tilman Keskinoz freebsd_committer freebsd_triage 2006-07-06 12:21:41 UTC
State Changed
From-To: open->closed

This one was committed by flz in January.