Page 1 of 1

CatchMusic - Invalid Memory Access (Read Error)

Posted: Tue Apr 29, 2025 5:14 pm
by Teddy Rogers
PureBasic 6.20 (x86 & x64), when running the code posted in the link below it crashes after a minute or so running. There is an invalid memory access (read error) in x86 and, in x64 the program simply crashes out with no error. Same problem exists with either ASM or C compilers.

https://www.purebasic.fr/english/viewto ... 15#p609915

I have the same problem trying XM modules I have with this code...

Code: Select all

If OpenWindow(0, 0, 0, 140, 80, "XM Music", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  If InitSound()
    XMMusic = CatchMusic(#PB_Any, ?ModuleStart, ?ModuleEnd-?ModuleStart)
    
    If IsMusic(XMMusic)
      MusicVolume(XMMusic, 5)
      PlayMusic(XMMusic)
    EndIf
  EndIf
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
  
EndIf

DataSection
  ModuleStart: 
  IncludeBinary "music1.xm"
  ModuleEnd:
EndDataSection
Ted.

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Tue Apr 29, 2025 5:35 pm
by Fred
Did you tried with lastest beta ?

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Tue Apr 29, 2025 5:52 pm
by Teddy Rogers
Apologies, I should have mentioned I had already tried the latest 6.21 beta 6 release, same issue.

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Wed Apr 30, 2025 6:58 am
by Teddy Rogers
I downloaded the demo version of 6.20 and installed it on a VM. I was able to get all working, no problems.

Compiled the PB demo version in the VM to an executable. Executed it on the machine where it crashes and, after a short time the executable crashed...

Ted.

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Wed Apr 30, 2025 8:05 am
by Fred
could you share your xm ? I tried with some here and it works as expected.

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Wed Apr 30, 2025 9:20 am
by Teddy Rogers
Using the data.b in the DataSection of this topic has the same results...

https://www.purebasic.fr/english/viewto ... 2e#p609915

Here is a compiled binary of that code, it works in a VM and, not on the host.

https://www.mediafire.com/file/aeq9fomi ... 2.exe/file

Ted.

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Wed Apr 30, 2025 10:19 am
by miso
In my example here I have an xm also embedded and catched from datasections, but it works. (Had different problems with the music commands though)

https://www.purebasic.fr/english/viewto ... 71#p637071

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Wed Apr 30, 2025 10:40 am
by Fred
I tried on both x64 and x86 and it works for more than 15mins with this code: https://www.purebasic.fr/english/viewto ... 2e#p609915

Can anyone else check ?

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Wed Apr 30, 2025 10:44 am
by miso
Firace's example works for me on win7 64 bit, roughly played it for ~5 mins.

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Wed Apr 30, 2025 1:26 pm
by Quin
Also works here on Windows 10 21H2 64-bit, both ASM and C backends. Let it play for around 20 minutes.

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Wed Apr 30, 2025 2:40 pm
by Teddy Rogers
Thank you for testing everyone. I compiled a 32bit version (see link to it below) and let it run in x64dbg.

https://www.mediafire.com/file/so6gu6lu ... 2.zip/file

This is the location and exception that it occurs (screenshot in the link)...

https://www.mediafire.com/view/co0ru4rc ... 2.jpg/file

Code: Select all

EXCEPTION_DEBUG_INFO:
           dwFirstChance: 1
           ExceptionCode: C0000005 (EXCEPTION_ACCESS_VIOLATION)
          ExceptionFlags: 00000000
        ExceptionAddress: test2.0045F3BE
        NumberParameters: 2
ExceptionInformation[00]: 00000000 Read
ExceptionInformation[01]: 03AFB000 Inaccessible Address
First chance exception on 0045F3BE (C0000005, EXCEPTION_ACCESS_VIOLATION)!
EXCEPTION_DEBUG_INFO:
           dwFirstChance: 0
           ExceptionCode: C0000005 (EXCEPTION_ACCESS_VIOLATION)
          ExceptionFlags: 00000000
        ExceptionAddress: test2.0045F3BE
        NumberParameters: 2
ExceptionInformation[00]: 00000000 Read
ExceptionInformation[01]: 03AFB000 Inaccessible Address
Last chance exception on 0045F3BE (C0000005, EXCEPTION_ACCESS_VIOLATION)!
Ted.

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Fri May 02, 2025 1:54 pm
by Fred
Unfortunately it will be hard for us to investigate if we can't reproduce it.

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Fri May 02, 2025 3:39 pm
by infratec
When it works in your VM, then you have a problem on the machine where it crashes.

I was also not able to reproduce your fault.

Have you already completely disabled all virus scanners? (for testing)

Re: CatchMusic - Invalid Memory Access (Read Error)

Posted: Mon May 12, 2025 1:29 pm
by Teddy Rogers
infratec wrote: Fri May 02, 2025 3:39 pm When it works in your VM, then you have a problem on the machine where it crashes.

I was also not able to reproduce your fault.

Have you already completely disabled all virus scanners? (for testing)
Apologies for the late reply, I had no time to look at this until just now. FYI it is not an issue with antivirus.
Fred wrote: Fri May 02, 2025 1:54 pm Unfortunately it will be hard for us to investigate if we can't reproduce it.
The sample rate seems to be locked to 48,000 Hz. Anything other than this value in Windows output settings triggers the crash...

Ted.