Author Topic: Access Violation Error in Allegro 5 audio init  (Read 13843 times)

0 Members and 1 Guest are viewing this topic.

Offline Forestidia86

  • Posts: 723
  • inactive
    • View Profile
Access Violation Error in Allegro 5 audio init
« on: November 25, 2017, 10:50:38 PM »
I hesitated to report this since I was using one of the test versions of lix and it's as well possible that my laptop had just "hiccups" then.

But since I got an error message I could as well post it; maybe it's of interest, maybe not.

It just happened when I started the game.

Looked through the log file and a message that could be related to it is:
0.18 Allegro 5 can't install audio

This gets printed from src/hardware/sound.d:
Code: [Select]
    // assumes Allegro has been initialized, but audio hasn't been initialized
    if (! al_install_audio())
        log("Allegro 5 can't install audio");

The rest from that day seems to be mostly complaining that translations are missing (due to v.0.9.2) and that I had a zip-file in the level folder, which couldn't be read.
« Last Edit: January 17, 2018, 08:34:29 AM by Simon »

Online Simon

  • Administrator
  • Posts: 3875
    • View Profile
    • Lix
Re: Access Violation Error
« Reply #1 on: November 26, 2017, 02:54:31 AM »
This looks like memory corruption. Especially at start of program, this should be a one-time error. Let's ignore it for now, but definitely post if you crash like this again.

Reason: You crash in al_create_voice, which, according to the call stack, is called from al_stricmp. But al_stricmp is a side-effect-free function to compare text strings, it definitely won't call al_create_voice, a sound routine. Since the call stack looks like this nonetheless, I suppose corrupt memory. Maybe Allegro was badly loaded this time. Maybe you ran out of free RAM. Maybe the RAM hardware has become faulty, but that is rare. Maybe there is a weird bug in Allegro or its D bindings. Definitely ignore and only investigate if it happens more often.

-- Simon

Offline Forestidia86

  • Posts: 723
  • inactive
    • View Profile
Re: Access Violation Error
« Reply #2 on: January 16, 2018, 01:08:26 AM »
Simon, Arty encountered a similiar error when running from the taskbar:

Arty mentioned in IRC:
[23:57:21]    <Arty_> OK. Every time I try to run Lix, I get an error: object.Error@(0): Access Violation. Followed by a bunch of hex numbers
[23:58:28]    <Arty_> Only when I run from the taskbar though

I've tried to reproduce it and it at first didn't give me the crash but now I could reproduce it (It doesn't happen every time but rather often):

The log.txt only says:
Lix version:  0.9.8
Session date: 2018-01-16 01:57:17
     0.06 Allegro 5 can't install audio

I've attached the crash message of the release build and the debug build.

Online Simon

  • Administrator
  • Posts: 3875
    • View Profile
    • Lix
Re: Access Violation Error in Allegro 5 audio init
« Reply #3 on: January 16, 2018, 03:03:07 AM »
Thanks, that's worrisome. At least it looks like the same crash from 2017-11. I haven't touched the audio initialization in over a year.

03:57 <SimonN> Arty_: which Lix version is that?
03:57 <Arty_> 0.9.7

These days, I'll look into building a debugging Lix against Allegro debugging libraries. I don't have good ideas other than brute-force reduction, find the minimal Allegro-calling usercode that still compiles and crashes like that.

-- Simon

Offline Forestidia86

  • Posts: 723
  • inactive
    • View Profile
Re: Access Violation Error in Allegro 5 audio init
« Reply #4 on: January 16, 2018, 03:32:57 AM »
I'm not really sure what the conditions for the crash for me are (v. 0.9.8). But some observations (not sure if they are really consistent):

Pattern for the inconsistent crash state:
If I have opened Lix otherwise then close and open from the taskbar I get the error.
If I have the error from the taskbar and open reasonably fast from the taskbar again I generally don't get the error. But if I wait some time (20 sec for example?) the error reoccurs.

Concerning consistent crash state:
Suddenly the error got consistent for me/ it crashes always when I click on the taskbar icon (after waiting time after having the crash but that doesn't cause it always). But I could "fix" it (error has gotten inconsistent again) by removing the link from the taskbar and putting it back on.
« Last Edit: January 16, 2018, 05:05:49 PM by Forestidia86 »

Offline Forestidia86

  • Posts: 723
  • inactive
    • View Profile
Re: Access Violation Error in Allegro 5 audio init
« Reply #5 on: January 16, 2018, 03:56:42 AM »
Only one addition:
I didn't manage to get the crash on the Win 8.1 laptop, yet. What OS does Arty have?
(Lix 0.9.4. hasn't given me the crash, yet either. Lix 0.9.6 seems to be the first version that gives me the task bar crash.)
« Last Edit: January 16, 2018, 05:13:33 PM by Forestidia86 »

Online Simon

  • Administrator
  • Posts: 3875
    • View Profile
    • Lix
Re: Access Violation Error in Allegro 5 audio init
« Reply #6 on: January 16, 2018, 04:04:36 AM »
<Arty> Windows 8.0

And thanks for the experiments, can be helpful to find theories later.

-- Simon

Offline Forestidia86

  • Posts: 723
  • inactive
    • View Profile
Re: Access Violation Error in Allegro 5 audio init
« Reply #7 on: January 16, 2018, 04:12:35 AM »
Yeah, sorry, I got it now reproduced with Win 8.1 as well, although it's very rare and inconsistent at the moment. (I fiddled around with changing from window to software fullscreen and back but I don't even know if this has anything to do with that.)

Offline Forestidia86

  • Posts: 723
  • inactive
    • View Profile
Re: Access Violation Error in Allegro 5 audio init
« Reply #8 on: January 16, 2018, 04:24:43 AM »
Sorry that I write again, but I think if you open Lix twice at the same time (or maybe a tiny bit delayed?) (e.g. one via link and one via exe) then the error can occur as well.

Just for clarification: Just one of the two instance crashes. I'm not really sure if it is consistent since it's quite fiddly to perform.
« Last Edit: January 16, 2018, 01:49:31 PM by Forestidia86 »

Offline Forestidia86

  • Posts: 723
  • inactive
    • View Profile
Re: Access Violation Error in Allegro 5 audio init
« Reply #9 on: January 16, 2018, 05:47:55 PM »
Sorry again, but one question: Could it be that fix #222 causes the task bar crash issue?
I reverted the commit in the 0.9.6 source (0.9.6 was the first version where I could reproduce the crash) and it doesn't seem to give me the crash although that doesn't have to mean anything since it is inconsistent for me anyways.
« Last Edit: January 16, 2018, 05:58:46 PM by Forestidia86 »

Online Simon

  • Administrator
  • Posts: 3875
    • View Profile
    • Lix
Re: Access Violation Error in Allegro 5 audio init
« Reply #10 on: January 16, 2018, 06:11:00 PM »
Well possible that such a change introduces bugs. It's a massive restructuring that allows complete deinitialization and re-initialization without terminating the app.

I'm not convinced because you had the first crash in late November, but 0.9.6 was a December release. Still, it might have made the crash more likely. Interesting find!

Don't apologize for posting several times. There is no downside to double posting; forums that discourage it have weird management. You should double post when you have substantial new information. This bumps the topic and the bot announces the new information in IRC, appropriately.

-- Simon

Online Simon

  • Administrator
  • Posts: 3875
    • View Profile
    • Lix
Re: Access Violation Error in Allegro 5 audio init
« Reply #11 on: January 16, 2018, 07:08:48 PM »
I find it extraordinary and super helpful that you're digging into the git history yourself.

I can't debug this crash on Linux. I could reduce and dish out debugging builds, but the test cycle is so much faster if you dig yourself. It's amazing help! Any such work is great, even if you can't form a theory yet!

-- Simon

Offline Forestidia86

  • Posts: 723
  • inactive
    • View Profile
Re: Access Violation Error in Allegro 5 audio init
« Reply #12 on: January 16, 2018, 07:31:49 PM »
Nevertheless it would be maybe good to have a debugging build against Allegro debug libraries, to see if there is something weird with Allegro.
With this bug I can't be sure of anything, since it is not as clear cut like others. In Win 8.1 I needed countless attempts and fiddling around with the settings to get to the crash, so it's deceiving.
I don't understand enough of the matter to really assess what can cause the bug and what not. So my reduction will generally not to the point.
Up until now we have three settings of the crash: my first crash (0.9.2), task bar (from 0.9.6 on?), double initialization (from 0.9.6 on?). I can't say how connected they are.
« Last Edit: January 17, 2018, 05:34:19 AM by Forestidia86 »

Online Simon

  • Administrator
  • Posts: 3875
    • View Profile
    • Lix
Re: Access Violation Error in Allegro 5 audio init
« Reply #13 on: January 16, 2018, 07:58:43 PM »
Debugging DLLs/LIBs in reply #35's attachment

Warning: I'm cheap and have given these the exact same name as the release dlls/libs. This has advantage and downside. Advantage is that you don't have to mess with dub.json, it will always build against whatever variant of Allegro you install to DMD dir. Downside is that you can't install both at same time.

Thus, usage:
1. Make backup of D/dmd2/windows/bin and D/dmd2/windows/lib.
2. Extract archive into D/dmd/windows, this should overwrite the Allegro files in bin and lib.
3. Rebuild Lix (can checkout any Lix version from git that you want) and repro crash
4. When done debugging, restore your DMD dir from the backups you made in step 1.

(How did I make these? I downloaded binary A5 release, discarded the release versions, kept the debugging versions, and made the lib files with implib as described in Lix build notes for Windows.)

-- Simon
« Last Edit: January 17, 2018, 01:45:18 PM by Simon »

Offline Forestidia86

  • Posts: 723
  • inactive
    • View Profile
Re: Access Violation Error in Allegro 5 audio init
« Reply #14 on: January 16, 2018, 08:33:43 PM »
Simon, I'm getting constantly errors that I'm missing DLLs. It started with that allegro-debug-5.2.dll is missing. Can you say which of the countless instances you used (static or dynamic?, i686 or x86_64?, 5.2.3.0 or ~.1?). Do I need MingW?

After several hours of testing around I don't think I can build it without help. I actually don't even know when I successfully build such a build against debugging libraries.
« Last Edit: January 16, 2018, 10:52:46 PM by Forestidia86 »