On Tue, Apr 19, 2016 at 10:57:38AM +0200, Caspar Schutijser wrote:
> Hi bugs@,
>
> On my laptop, wsconsctl crashes with a floating point exception when it
> wants to print keyboard.backlight. It divides by 0.
>
> Below is a patch that fixes the issue, output from gdb and my dmesg.
Yes this is a known problem. There were some suggestion to fix this not
in wsconsctl (but instead in acpithinkpad?).
> Best regards,
> Caspar Schutijser
>
>
>
> Index: util.c
> ===================================================================
> RCS file: /cvs/src/sbin/wsconsctl/util.c,v
> retrieving revision 1.63
> diff -u -p -r1.63 util.c
> --- util.c 10 Feb 2016 05:49:50 -0000 1.63
> +++ util.c 19 Apr 2016 08:47:31 -0000
> @@ -261,7 +261,8 @@ pr_field(const char *pre, struct field *
> pc = f->valp;
> i = pc->max - pc->min;
> n = pc->cur - pc->min;
> - printf("%u.%02u%%", n * 100 / i, ((n * 100) % i) * 100 / i);
> + printf("%u.%02u%%", i == 0 ? 0 : (n * 100 / i),
> + i == 0 ? 0 : ((n * 100) % i) * 100 / i);
> break;
> case FMT_KBDTYPE:
> p = int2name(*((u_int *) f->valp), 1,
>
>
> # egdb /usr/src/sbin/wsconsctl/wsconsctl
> GNU gdb (GDB) 7.11
> Copyright (C) 2016 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law. Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-unknown-openbsd5.9".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>.
> Find the GDB manual and other documentation resources online at:
> <http://www.gnu.org/software/gdb/documentation/>.
> For help, type "help".
> Type "apropos word" to search for commands related to "word"...
> Reading symbols from /usr/src/sbin/wsconsctl/wsconsctl...done.
> (gdb) r
> Starting program: /home/caspar/src/openbsd-src/sbin/wsconsctl/wsconsctl
> keyboard.type=pc-xt
> keyboard.bell.pitch=400
> keyboard.bell.period=100
> keyboard.bell.volume=0
> keyboard.bell.pitch.default=400
> keyboard.bell.period.default=100
> keyboard.bell.volume.default=50
> wsconsctl: Use explicit arg to view keyboard.map.
> keyboard.repeat.del1=400
> keyboard.repeat.deln=100
> keyboard.repeat.del1.default=400
> keyboard.repeat.deln.default=100
> keyboard.ledstate=0
> keyboard.encoding=us
>
> Program received signal SIGFPE, Arithmetic exception.
> 0x000005240400c0fc in pr_field (pre=<optimized out>, f=0x5240442f5d0
> <keyboard_field_tab+336>, sep=<optimized out>) at util.c:264
> 264 printf("%u.%02u%%", n * 100 / i, ((n * 100) % i) *
> 100 / i);
> (gdb) bt
> #0 0x000005240400c0fc in pr_field (pre=<optimized out>, f=0x5240442f5d0
> <keyboard_field_tab+336>, sep=<optimized out>)
> at util.c:264
> #1 0x000005240400c81e in main (argc=0, argv=<optimized out>) at
> wsconsctl.c:155
> (gdb) print i
> $1 = 0
> (gdb) print *f
> $2 = {name = 0x52404126cd8 "backlight", valp = 0x524044330c0 <backlight>,
> format = 4, flags = 1288}
>
>
> OpenBSD 5.9-current (GENERIC.MP) #1986: Sun Apr 17 18:02:42 MDT 2016
> [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> real mem = 8283222016 (7899MB)
> avail mem = 8027799552 (7655MB)
> mpath0 at root
> scsibus0 at mpath0: 256 targets
> mainbus0 at root
> bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xdae9d000 (69 entries)
> bios0: vendor LENOVO version "G4ET37WW (1.12 )" date 05/29/2012
> bios0: LENOVO 2429DT7
> acpi0 at bios0: rev 2
> acpi0: sleep states S0 S3 S4 S5
> acpi0: tables DSDT FACP SLIC TCPA SSDT SSDT SSDT HPET APIC MCFG ECDT FPDT
> ASF! UEFI UEFI POAT SSDT SSDT UEFI
> acpi0: wakeup devices LID_(S4) SLPB(S3) IGBE(S4) EXP3(S4) XHCI(S3) EHC1(S3)
> EHC2(S3) HDEF(S4)
> acpitimer0 at acpi0: 3579545 Hz, 24 bits
> acpihpet0 at acpi0: 14318179 Hz
> acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
> cpu0 at mainbus0: apid 0 (boot processor)
> cpu0: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz, 2295.19 MHz
> cpu0:
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS,SENSOR,ARAT
> cpu0: 256KB 64b/line 8-way L2 cache
> cpu0: smt 0, core 0, package 0
> mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
> cpu0: apic clock running at 99MHz
> cpu0: mwait min=64, max=64, C-substates=0.2.1.1.2, IBE
> cpu1 at mainbus0: apid 1 (application processor)
> cpu1: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz, 2294.79 MHz
> cpu1:
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS,SENSOR,ARAT
> cpu1: 256KB 64b/line 8-way L2 cache
> cpu1: smt 1, core 0, package 0
> cpu2 at mainbus0: apid 2 (application processor)
> cpu2: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz, 2294.79 MHz
> cpu2:
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS,SENSOR,ARAT
> cpu2: 256KB 64b/line 8-way L2 cache
> cpu2: smt 0, core 1, package 0
> cpu3 at mainbus0: apid 3 (application processor)
> cpu3: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz, 2294.79 MHz
> cpu3:
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS,SENSOR,ARAT
> cpu3: 256KB 64b/line 8-way L2 cache
> cpu3: smt 1, core 1, package 0
> cpu4 at mainbus0: apid 4 (application processor)
> cpu4: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz, 2294.79 MHz
> cpu4:
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS,SENSOR,ARAT
> cpu4: 256KB 64b/line 8-way L2 cache
> cpu4: smt 0, core 2, package 0
> cpu5 at mainbus0: apid 5 (application processor)
> cpu5: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz, 2294.79 MHz
> cpu5:
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS,SENSOR,ARAT
> cpu5: 256KB 64b/line 8-way L2 cache
> cpu5: smt 1, core 2, package 0
> cpu6 at mainbus0: apid 6 (application processor)
> cpu6: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz, 2294.79 MHz
> cpu6:
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS,SENSOR,ARAT
> cpu6: 256KB 64b/line 8-way L2 cache
> cpu6: smt 0, core 3, package 0
> cpu7 at mainbus0: apid 7 (application processor)
> cpu7: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz, 2294.79 MHz
> cpu7:
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS,SENSOR,ARAT
> cpu7: 256KB 64b/line 8-way L2 cache
> cpu7: smt 1, core 3, package 0
> ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 20, 24 pins
> acpimcfg0 at acpi0 addr 0xf8000000, bus 0-63
> acpiec0 at acpi0
> acpiprt0 at acpi0: bus 0 (PCI0)
> acpiprt1 at acpi0: bus -1 (PEG_)
> acpiprt2 at acpi0: bus 2 (EXP1)
> acpiprt3 at acpi0: bus 3 (EXP2)
> acpiprt4 at acpi0: bus -1 (EXP3)
> acpicpu0 at acpi0: C2(350@80 mwait.1@0x20), C1(1000@1 mwait.1), PSS
> acpicpu1 at acpi0: C2(350@80 mwait.1@0x20), C1(1000@1 mwait.1), PSS
> acpicpu2 at acpi0: C2(350@80 mwait.1@0x20), C1(1000@1 mwait.1), PSS
> acpicpu3 at acpi0: C2(350@80 mwait.1@0x20), C1(1000@1 mwait.1), PSS
> acpicpu4 at acpi0: C2(350@80 mwait.1@0x20), C1(1000@1 mwait.1), PSS
> acpicpu5 at acpi0: C2(350@80 mwait.1@0x20), C1(1000@1 mwait.1), PSS
> acpicpu6 at acpi0: C2(350@80 mwait.1@0x20), C1(1000@1 mwait.1), PSS
> acpicpu7 at acpi0: C2(350@80 mwait.1@0x20), C1(1000@1 mwait.1), PSS
> acpipwrres0 at acpi0: PUBS, resource for XHCI, EHC1, EHC2
> acpitz0 at acpi0: critical temperature is 103 degC
> acpibtn0 at acpi0: LID_
> acpibtn1 at acpi0: SLPB
> "PNP0103" at acpi0 not configured
> "PNP0303" at acpi0 not configured
> "LEN0015" at acpi0 not configured
> "PNP0C09" at acpi0 not configured
> acpibat0 at acpi0: BAT0 model "45N1013" serial 19816 type LION oem "SANYO"
> acpiac0 at acpi0: AC unit online
> acpithinkpad0 at acpi0
> "PNP0C14" at acpi0 not configured
> "PNP0C14" at acpi0 not configured
> acpivideo0 at acpi0: VID_
> acpivout at acpivideo0 not configured
> acpivideo1 at acpi0: VID_
> cpu0: Enhanced SpeedStep 2295 MHz: speeds: 2301, 2300, 2200, 2100, 2000,
> 1900, 1800, 1700, 1600, 1500, 1400, 1300, 1200 MHz
> pci0 at mainbus0 bus 0
> pchb0 at pci0 dev 0 function 0 "Intel Core 3G Host" rev 0x09
> inteldrm0 at pci0 dev 2 function 0 "Intel HD Graphics 4000" rev 0x09
> drm0 at inteldrm0
> inteldrm0: msi
> inteldrm0: 1600x900
> wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation)
> wsdisplay0: screen 1-5 added (std, vt100 emulation)
> xhci0 at pci0 dev 20 function 0 "Intel 7 Series xHCI" rev 0x04: msi
> usb0 at xhci0: USB revision 3.0
> uhub0 at usb0 "Intel xHCI root hub" rev 3.00/1.00 addr 1
> "Intel 7 Series MEI" rev 0x04 at pci0 dev 22 function 0 not configured
> em0 at pci0 dev 25 function 0 "Intel 82579LM" rev 0x04: msi, address
> 3c:97:0e:22:0a:b0
> ehci0 at pci0 dev 26 function 0 "Intel 7 Series USB" rev 0x04: apic 2 int 16
> usb1 at ehci0: USB revision 2.0
> uhub1 at usb1 "Intel EHCI root hub" rev 2.00/1.00 addr 1
> azalia0 at pci0 dev 27 function 0 "Intel 7 Series HD Audio" rev 0x04: msi
> azalia0: codecs: Realtek ALC269
> audio0 at azalia0
> ppb0 at pci0 dev 28 function 0 "Intel 7 Series PCIE" rev 0xc4: msi
> pci1 at ppb0 bus 2
> sdhc0 at pci1 dev 0 function 0 "Ricoh 5U823 SD/MMC" rev 0x05: apic 2 int 16
> sdmmc0 at sdhc0
> ppb1 at pci0 dev 28 function 1 "Intel 7 Series PCIE" rev 0xc4: msi
> pci2 at ppb1 bus 3
> iwn0 at pci2 dev 0 function 0 "Intel Centrino Advanced-N 6205" rev 0x34: msi,
> MIMO 2T2R, MoW, address 60:67:20:44:f9:84
> ehci1 at pci0 dev 29 function 0 "Intel 7 Series USB" rev 0x04: apic 2 int 23
> usb2 at ehci1: USB revision 2.0
> uhub2 at usb2 "Intel EHCI root hub" rev 2.00/1.00 addr 1
> pcib0 at pci0 dev 31 function 0 "Intel QM77 LPC" rev 0x04
> ahci0 at pci0 dev 31 function 2 "Intel 7 Series AHCI" rev 0x04: msi, AHCI 1.3
> ahci0: port 0: 6.0Gb/s
> ahci0: port 1: 1.5Gb/s
> scsibus1 at ahci0: 32 targets
> sd0 at scsibus1 targ 0 lun 0: <ATA, Samsung SSD 850, EMT0> SCSI3 0/direct
> fixed naa.5002538d401db2c2
> sd0: 476940MB, 512 bytes/sector, 976773168 sectors, thin
> cd0 at scsibus1 targ 1 lun 0: <Optiarc, DVD RW AD-7740H, 1.S0> ATAPI 5/cdrom
> removable
> ichiic0 at pci0 dev 31 function 3 "Intel 7 Series SMBus" rev 0x04: apic 2 int
> 18
> iic0 at ichiic0
> spdmem0 at iic0 addr 0x50: 4GB DDR3 SDRAM PC3-12800 SO-DIMM
> spdmem1 at iic0 addr 0x51: 4GB DDR3 SDRAM PC3-12800 SO-DIMM
> isa0 at pcib0
> isadma0 at isa0
> pckbc0 at isa0 port 0x60/5 irq 1 irq 12
> pckbd0 at pckbc0 (kbd slot)
> wskbd0 at pckbd0: console keyboard, using wsdisplay0
> pms0 at pckbc0 (aux slot)
> wsmouse0 at pms0 mux 0
> wsmouse1 at pms0 mux 0
> pms0: Synaptics touchpad, firmware 7.2
> pcppi0 at isa0 port 0x61
> spkr0 at pcppi0
> sdmmc0: can't enable card
> uhidev0 at uhub0 port 1 configuration 1 interface 0 "Holtek USB Keyboard" rev
> 1.10/1.01 addr 2
> uhidev0: iclass 3/1
> ukbd0 at uhidev0: 8 variable keys, 6 key codes
> wskbd1 at ukbd0 mux 1
> wskbd1: connecting to wsdisplay0
> uhidev1 at uhub0 port 1 configuration 1 interface 1 "Holtek USB Keyboard" rev
> 1.10/1.01 addr 2
> uhidev1: iclass 3/1, 2 report ids
> uhid0 at uhidev1 reportid 1: input=6, output=0, feature=0
> uhid1 at uhidev1 reportid 2: input=1, output=0, feature=0
> uhidev2 at uhub0 port 2 configuration 1 interface 0 "Logitech USB Laser
> Mouse" rev 2.00/56.01 addr 3
> uhidev2: iclass 3/1
> ums0 at uhidev2: 8 buttons, Z and W dir
> wsmouse2 at ums0 mux 0
> uhub3 at uhub1 port 1 "Intel Rate Matching Hub" rev 2.00/0.00 addr 2
> uhub4 at uhub2 port 1 "Intel Rate Matching Hub" rev 2.00/0.00 addr 2
> vscsi0 at root
> scsibus2 at vscsi0: 256 targets
> softraid0 at root
> scsibus3 at softraid0: 256 targets
> sd1 at scsibus3 targ 1 lun 0: <OPENBSD, SR CRYPTO, 006> SCSI2 0/direct fixed
> sd1: 386932MB, 512 bytes/sector, 792437664 sectors
> root on sd1a (e5feaad7e6d89dfd.a) swap on sd1b dump on sd1b
>