Bug 282521 - audio/libsidplayfp: 2.8.0 fails with bus error
Summary: audio/libsidplayfp: 2.8.0 fails with bus error
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: Dima Panov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-03 15:59 UTC by Dirk Meyer
Modified: 2024-11-26 00:20 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (fluffy)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Meyer freebsd_committer freebsd_triage 2024-11-03 15:59:49 UTC
FreeBSD 14.1 amd64

# pkg info -g '*sid*'
libsidplayfp-2.8.0
sidplayfp-2.10.0

replacing sidplayer2 with sidplayerfx

$ sidplayfp Last_Ninja.sid
+------------------------------------------------------+
|  SIDPLAYFP - Music Player and C64 SID Chip Emulator  |
|        Sidplayfp V2.10.0, Libsidplayfp V2.8.0        |
+------------------------------------------------------+
| Title        : The Last Ninja                        |
| Author       : Ben Daglish & Anthony Lees            |
| Released     : 1987 System 3                         |
+------------------------------------------------------+
| Playlist     : 1/11 (tune 3/11[3])                   |
| Song Length  : NO SLDB                               |
+------------------------------------------------------+
| Kernal ROM   : None - Some tunes may not play!       |
| BASIC ROM    : None - Basic tunes will not play!     |
| Chargen ROM  : None                                  |
+------------------------------------------------------+
Playing, press ESC to stop...Bus error(core dumped)

File did play with sidplayer, sidplay and sidplay2
Comment 1 Daniel Engberg freebsd_committer freebsd_triage 2024-11-04 23:53:24 UTC
Possibly because the mismatch between libsidplayfp and sidplayfp?
I have a PR open for bumping libsidplayfp here, https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=282276

Best regards,
Daniel
Comment 2 Dirk Meyer freebsd_committer freebsd_triage 2024-11-07 09:38:36 UTC
I tried 20 more .sid files fro, HVSC
all leads to "bus error."

I had both compiled clean:
-rw-r--r--  1 root wheel 121851 27 Okt. 04:11 log-bamd14/build,audio,libsidplayfp
-rw-r--r--  1 root wheel  19194 27 Okt. 04:11 log-bamd14/build,audio,sidplayfp

libsidplayfp-2.8.0
sidplayfp-2.10.0

$ ldd /usr/local/bin/sidplayfp 
/usr/local/bin/sidplayfp:
        libsidplayfp.so.6 => /usr/local/lib/libsidplayfp.so.6 (0x28b2101c2000)
        libout123.so.0 => /usr/local/lib/libout123.so.0 (0x28b20e679000)
        libomp.so => /usr/lib/libomp.so (0x28b20f2af000)
        libc++.so.1 => /lib/libc++.so.1 (0x28b211e3b000)
        libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x28b2122c5000)
        libm.so.5 => /lib/libm.so.5 (0x28b2134b5000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x28b21239b000)
        libc.so.7 => /lib/libc.so.7 (0x28b214350000)
        libgcrypt.so.20 => /usr/local/lib/libgcrypt.so.20 (0x28b21553c000)
        libthr.so.3 => /lib/libthr.so.3 (0x28b212634000)
        libgpg-error.so.0 => /usr/local/lib/libgpg-error.so.0 (0x28b215bec000)
        libintl.so.8 => /usr/local/lib/libintl.so.8 (0x28b216ea3000)
        [vdso] (0x28b20ddca000)
Comment 3 Dirk Meyer freebsd_committer freebsd_triage 2024-11-07 09:50:58 UTC
I updated Libsidplayfp,
no change:

+------------------------------------------------------+
|  SIDPLAYFP - Music Player and C64 SID Chip Emulator  |
|       Sidplayfp V2.10.0, Libsidplayfp V2.11.0        |
+------------------------------------------------------+
| Title        : Lost Robot II (preview)               |
| Author       : Sven Forstmann <?>                    |
| Released     : 2002 Sven Forstmann                   |
+------------------------------------------------------+
| Playlist     : 1/2 (tune 1/2[1])                     |
| Song Length  : NO SLDB                               |
+------------------------------------------------------+
| Kernal ROM   : None - Some tunes may not play!       |
| BASIC ROM    : None - Basic tunes will not play!     |
| Chargen ROM  : None                                  |
+------------------------------------------------------+
Playing, press ESC to stop...Bus error(core dumped)

I updated sidplayfp,
no change:

+------------------------------------------------------+
|  SIDPLAYFP - Music Player and C64 SID Chip Emulator  |
|       Sidplayfp V2.11.0, Libsidplayfp V2.11.0        |
+------------------------------------------------------+
| Title        : Lost Robot II (preview)               |
| Author       : Sven Forstmann <?>                    |
| Released     : 2002 Sven Forstmann                   |
+------------------------------------------------------+
| Playlist     : 1/2 (tune 1/2[1])                     |
| Song Length  : NO SLDB                               |
+------------------------------------------------------+
| Kernal ROM   : None - Some tunes may not play!       |
| BASIC ROM    : None - Basic tunes will not play!     |
| Chargen ROM  : None                                  |
+------------------------------------------------------+
Playing, press ESC to stop...Bus error(core dumped)



Next rebuilding libsidplayfp with DEBUG and symbols:
no change:

Makefile.local:
OPTIONS_SET+=   DEBUG
WITH_DEBUG=yes
DEBUG_FLAGS= -g -O1

Core was generated by `sidplayfp HVSC/C64Music/GAMES/G-L/Lost_Robot_II_preview.sid'.
Program terminated with signal SIGBUS, Bus error.
Object-specific hardware error.
#0  reSIDfp::convolve (a=0x589ddbf4cdc, b=0x589ddb9a000, bLength=99)
    at src/builders/residfp-builder/residfp/resample/SincResampler.cpp:122

warning: 122    src/builders/residfp-builder/residfp/resample/SincResampler.cpp: No such file or directory
(gdb) bt
#0  reSIDfp::convolve (a=0x589ddbf4cdc, b=0x589ddb9a000, bLength=99)
    at src/builders/residfp-builder/residfp/resample/SincResampler.cpp:122
#1  reSIDfp::SincResampler::fir (this=this@entry=0x589ddbf2e40, subcycle=subcycle@entry=0)
    at src/builders/residfp-builder/residfp/resample/SincResampler.cpp:241
#2  0x0000000821598a62 in reSIDfp::SincResampler::input (this=0x589ddbf2e40, input=<optimized out>)
    at src/builders/residfp-builder/residfp/resample/SincResampler.cpp:362
#3  0x00000008215981a2 in reSIDfp::TwoPassSincResampler::input (this=0x589dda1d040, sample=0)
    at src/builders/residfp-builder/residfp/resample/TwoPassSincResampler.h:77
#4  0x0000000821591acf in reSIDfp::SID::clock (this=0x589dda851c0, cycles=40, buf=0x589ddb8b000)
    at src/builders/residfp-builder/residfp/SID.h:372
#5  0x0000000821591760 in libsidplayfp::ReSIDfp::clock (this=0x589dda5f080)
    at src/builders/residfp-builder/residfp-emu.cpp:105
#6  libsidplayfp::ReSIDfp::write (this=0x589dda5f080, addr=24 '\030', data=15 '\017')
    at src/builders/residfp-builder/residfp-emu.cpp:97
#7  0x00000008215869af in libsidplayfp::MOS6510::eventWithoutSteals (this=0x589dda45758)
    at src/c64/CPU/mos6510.cpp:66
#8  libsidplayfp::FastEventCallback<libsidplayfp::MOS6510, &libsidplayfp::MOS6510::eventWithoutSteals>::event (this=<optimized out>) at ./src/EventCallback.h:62
#9  0x000000082157ba19 in libsidplayfp::EventScheduler::clock (this=0x589dda2f960)
    at ./src/EventScheduler.h:141
#10 libsidplayfp::c64::clock (this=0x589dda2f940) at src/c64/c64.h:202
#11 libsidplayfp::Player::run (this=0x589dda2f940, events=3000) at src/player.cpp:208
#12 libsidplayfp::Player::play (this=0x589dda2f940, buffer=<optimized out>, count=11025)
    at src/player.cpp:253
#13 0x0000000000217194 in ?? ()
#14 0x00000000002106b8 in ?? ()
#15 0x0000000825e49a6a in __libc_start1 (argc=2, argv=0x820652558, env=0x820652570, 
    cleanup=<optimized out>, mainX=0x2105c0) at /usr/src/lib/libc/csu/libc_start1.c:157
#16 0x000000000020b590 in ?? ()
Comment 4 Dirk Meyer freebsd_committer freebsd_triage 2024-11-07 10:07:07 UTC
Installing from "pkg+http://pkg.FreeBSD.org/${ABI}/latest" 

+------------------------------------------------------+
|  SIDPLAYFP - Music Player and C64 SID Chip Emulator  |
|        Sidplayfp V2.11.0, Libsidplayfp V2.8.0        |
+------------------------------------------------------+
| Title        : Lost Robot II (preview)               |
| Author       : Sven Forstmann <?>                    |
| Released     : 2002 Sven Forstmann                   |
+------------------------------------------------------+
| Playlist     : 1/2 (tune 1/2[1])                     |
| Song Length  : NO SLDB                               |
+------------------------------------------------------+
| Kernal ROM   : None - Some tunes may not play!       |
| BASIC ROM    : None - Basic tunes will not play!     |
| Chargen ROM  : None                                  |
+------------------------------------------------------+
Playing, press ESC to stop...Bus error(core dumped)
Comment 5 Dirk Meyer freebsd_committer freebsd_triage 2024-11-07 11:33:37 UTC
Verified that the CPU supports SSE4.2:

CPU: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz (2400.00-MHz K8-class CPU)
  Origin="GenuineIntel"  Id=0x406e3  Family=0x6  Model=0x4e  Stepping=3
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x7ffafbbf<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,EST,TM2,SSSE3,SDBG,FMA,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND>
  AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
  AMD Features2=0x121<LAHF,ABM,Prefetch>
  Structured Extended Features=0x29c67af<FSGSBASE,TSCADJ,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,NFPUSG,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PROCTRACE>
  XSAVE Features=0xf<XSAVEOPT,XSAVEC,XINUSE,XSAVES>
  VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID
  TSC: P-state invariant, performance statistics


CPU: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz (2419.20-MHz K8-class CPU)
  Origin="GenuineIntel"  Id=0x806c1  Family=0x6  Model=0x8c  Stepping=1
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x7ffafbbf<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,EST,TM2,SSSE3,SDBG,FMA,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND>
  AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
  AMD Features2=0x121<LAHF,ABM,Prefetch>
  Structured Extended Features=0xf3bfa7eb<FSGSBASE,TSCADJ,BMI1,AVX2,FDPEXC,SMEP,BMI2,ERMS,INVPCID,NFPUSG,PQE,AVX512F,AVX512DQ,RDSEED,ADX,SMAP,AVX512IFMA,CLFLUSHOPT,CLWB,PROCTRACE,AVX512CD,SHA,AVX512BW,AVX512VL>
  Structured Extended Features2=0x18c05fde<AVX512VBMI,UMIP,PKU,OSPKE,AVX512VBMI2,GFNI,VAES,VPCLMULQDQ,AVX512VNNI,AVX512BITALG,AVX512VPOPCNTDQ,RDPID,MOVDIRI,MOVDIR64B>
  Structured Extended Features3=0xfc100510<FSRM,AVX512VP2INTERSECT,MD_CLEAR,IBT,IBPB,STIBP,L1DFL,ARCH_CAP,CORE_CAP,SSBD>
  XSAVE Features=0xf<XSAVEOPT,XSAVEC,XINUSE,XSAVES>
  IA32_ARCH_CAPS=0x6b<RDCL_NO,IBRS_ALL,SKIP_L1DFL_VME,MDS_NO>
  VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID,VID,PostIntr
  TSC: P-state invariant, performance statistics
Comment 6 Dima Panov freebsd_committer freebsd_triage 2024-11-07 20:02:58 UTC
(In reply to Dirk Meyer from comment #5)
Please try to rebuild libsidplayfp with

LDFLAGS+= -lpthrrad
Comment 7 Dirk Meyer freebsd_committer freebsd_triage 2024-11-08 18:26:10 UTC
Thanks for looking into it.

With the poudriere build, starting "sidplayfx" failed with:
ld-elf.so.1: /usr/local/lib/libsidplayfp.so.6: Undefined symbol "pthread_create"

The LDFLAGS fixes this problem.

The original Problem "Bus error(core dumped)" still happens.

I guess that clangs creates an instruction that my CPU can't handle,
or it may be an alignment issue for SSE4.2 data.
Comment 8 Daniel Engberg freebsd_committer freebsd_triage 2024-11-10 22:14:53 UTC
Works for me (tm) with current versions in tree after adding LDFLAGS+= -lpthread to libsidplayfp port Makefile.

Tested with out123 backend
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-11-10 22:24:38 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0fa10d205ec7a60c0179a54509dbfd7619ee4168

commit 0fa10d205ec7a60c0179a54509dbfd7619ee4168
Author:     Dima Panov <fluffy@FreeBSD.org>
AuthorDate: 2024-11-10 22:21:12 +0000
Commit:     Dima Panov <fluffy@FreeBSD.org>
CommitDate: 2024-11-10 22:21:12 +0000

    audio/libsidplayfp: force link with pthreads (+)

    This fixes runtime error:
    ld-elf.so.1: /usr/local/lib/libsidplayfp.so.6: Undefined symbol "pthread_create"

    PR:     282521

 audio/libsidplayfp/Makefile | 3 +++
 1 file changed, 3 insertions(+)