Lemmings Forums

Lix => Lix Main => Topic started by: Forestidia86 on November 25, 2017, 10:50:38 PM

Title: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 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.
Title: Re: Access Violation Error
Post by: Simon 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
Title: Re: Access Violation Error
Post by: Forestidia86 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.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon 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
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 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.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 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.)
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon 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
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 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.)
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 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.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on January 16, 2018, 05:47:55 PM
Sorry again, but one question: Could it be that fix #222 (https://github.com/SimonN/LixD/commit/165d0d0e1c6c53a57ed2618c7022fc987e8c3bb8) 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.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon 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
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon 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
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 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.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 16, 2018, 07:58:43 PM
Debugging DLLs/LIBs in reply #35's attachment (https://www.lemmingsforums.net/index.php?topic=3594.msg68964#msg68964)

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 (https://github.com/liballeg/allegro5/releases), discarded the release versions, kept the debugging versions, and made the lib files with implib as described in Lix build notes for Windows.)

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 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.
Title: Re: Access Violation Error
Post by: ccexplore on January 16, 2018, 11:48:56 PM
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.

It's more likely the callstack information displayed is not completely accurate.  This can happen particularly with release builds since an accurate callstack requires knowing the memory addresses in the DLL/EXE of every public and private function (ie. a name <-> address mapping).  This is extra data that either has to be carried in the DLL, or be provided in some supplementary file.  Without such information, the only related information left are the addresses of functions exported by the DLL/EXE to be called by external callers (eg. entry-point functions like "main", and the functions the DLL provided to external callers).  The callstack may show al_stricmp only because it happens to be the closest known address in the DLL to the numeric address value observed in the callstack.  It may actually be some private audio function in Allegro that cannot be mapped to a name at runtime, since there is no information about that function name and address.

Hopefully a debug build of Allegro may be more complete wrt to addresses for callstack.

I'm also wondering if a web search may find more information, I suspect the underlying issue probably isn't that uncommon, so even a search for the symbols called out in the callstack (al_stricmp, al_create_voice, etc.) may yield useful hits despite inaccuracies, simply because someone else may have reported or asked about a very similar callstack in their own programs as well.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 03:14:22 AM
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.

New try: Debugging DLLs/LIBs in reply #35's attachment (https://www.lemmingsforums.net/index.php?topic=3594.msg68964#msg68964). I didn't test anything earlier -- I made the archive, uploaded, and went to bed.

For both archives, I used allegro-i686-w64-mingw32-gcc-7.2.0-posix-dwarf-dynamic-5.2.3.1.zip.

I can probably rename the .libs as I want; at least when assuming the crazy workstyle that replaces release libs with debugging libs in the global compiler directory. But I shouldn't have renamed the DLLs. The DLLs should be called exactly as the your DLL-not-found error wants them.

If the DLLs are not found at runtime, even though you put correctly-named DLLs into the DMD dir, then put the DLLs in the game directory instead.

Quote from: ccexplore
The callstack may show al_stricmp only because it happens to be the closest known address in the DLL to the numeric address value observed in the callstack.  It may actually be some private audio function in Allegro that cannot be mapped to a name at runtime, since there is no information about that function name and address.

This is excellent insight. Thanks!

I didn't suspect this, I thought memory corruption was the only explanation. But in these January 2018 crash reports, the exact same message reproduces too well, it's probably not memory corruption.

At least I'm happy that I came to the same conclusion that A5 debugging builds might help.

No results for quick web search for crashes in al_create_voice. Tried some variation, but whenever the search becomes too detailed, it finds only this very thread, plus maybe raw Allegro source files. <_<;

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on January 17, 2018, 03:27:11 AM
I think I even tried something like that and it builds and runs but I can't find any log when I get the crash and the error message stays basically the same. (But it looks like I made a debug Allegro build. Not really I just misunderstood something.) Where to find the extra information?
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 04:09:24 AM
Oh, okay. If the crash log or dialog box remains the same like this, then I don't have good advice anymore. :-/

In my source code, I log the error that audio cannot be installed, but still continue happily after.

Speculation {
After I notice that Allegro 5 fails to install audio, it is a bug in Lix to blissfully call any more Allegro 5 audio functions. The crash happens because I do. The real issue is what prevents Allegro 5 from installing audio in the first place. The problem happens before the crash.
}

This means that I should build a small example program that initializes audio. This example should then be run under the crashy conditions, to see if installation of audio fails.

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 04:12:57 AM
When you ran against debugging libs, did Lix produce allegro.log? Post that if it did.

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on January 17, 2018, 04:32:23 AM
When you ran against debugging libs, did Lix produce allegro.log? Post that if it did.

That's actually the problem that I don't see any. That's why I'm not fully sure if I run against debug libs.
I had an allegro.log as I tried crazy things like putting your dlls with and without -debug in bin but then I think it needed dlls that come with MinGW and it crashed when started with a message from a c++-application.

The error message for the task bar crash always mentions places in allegro code: system.d(45) and system.d(62). Doesn't that mean anything?

Edit: I'm getting more and more the impression that I didn't manage to link against debugging libraries. The only setting where I seemed to have done it, the game refused to run completely (but got allegro.log there).
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 04:59:52 AM
Quote
system.d(45) and system.d(62). Doesn't that mean anything?

This is inside a wrapper function that runs all my Allegro-5-calling usercode. It merely means that I run everything through al_run_main, as is required by the D bindings. This is not specific to the sound because nearly my entire program comes after that.

I assume this appears at the bottom of the call stack, wherease al_stricmp, al_create_voice and friends appear near the top of the call stack.

Based on my speculation from earlier, I'll try to fix the crash in the next version and continue without sound, not calling any Allegro 5 sound functions that look crashing.

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 07:06:11 AM
It's an Allegro issue, most likely. I found exact same bug report on Allegro's forums: Running game from quicklaunch bar fails al_install_audio on Windows 7.

https://www.allegro.cc/forums/thread/616302

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on January 17, 2018, 07:15:48 AM
Can it be related to the taskbar issue concerning software fullscreen on Win 7? On the Win 8.1 laptop I don't have the fullscreen taskbar issue and the taskbar crash is rare and hard to get. Although Arty has Win 8.0 and consistent crash.

What bugs me is that I don't get an allegro.log. I don't know why.

But nevertheless before fix #222 the crash doesn't seem so likely. Maybe ask Arty if he has the issue with an Lix instance earlier than 0.9.6.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 07:39:59 AM
Can it be related to the taskbar issue concerning software fullscreen on Win 7? On the Win 8.1 laptop I don't have the fullscreen taskbar issue and the taskbar crash is rare and hard to get. Although Arty has Win 8.0 and consistent crash.

I don't remember the taskbar issue re fullscreen. <_<;; I suppose it wasn't #262 (https://github.com/SimonN/LixD/issues/262) (Fullscreen, can't switch to other windows, Windows)?

Quote
What bugs me is that I don't get an allegro.log. I don't know why.

There's always a chance that I made a mistake in preparing the dll/lib archives. If you'd really like to try again: Get an A5 binary release (https://github.com/liballeg/allegro5/releases) and generate the lib files with implib. I don't remember how to write a shell loop in Windows batch.

Quote
But nevertheless before fix #222 the crash doesn't seem so likely. Maybe ask Arty if he has the issue with an Lix instance earlier than 0.9.6.

He never complained before 0.9.8, but I can ask again to be sure.

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on January 17, 2018, 07:50:25 AM
I don't remember the taskbar issue re fullscreen. <_<;; I suppose it wasn't #262 (https://github.com/SimonN/LixD/issues/262) (Fullscreen, can't switch to other windows, Windows)?

I actually meant this issue. I have weird taskbar problems there, that I can't make other windows appear (on old Win 7 laptop) if I have software fullscreen and click on the taskbar after using the Win key .

Description (https://www.lemmingsforums.net/index.php?topic=3659.msg68697#msg68697):
Quote
Using the Win key: Clicking on other tabs on the Taskbar doesn't seem to produce visible/overlapping windows (at least for me). But if you use the Start menu as is activated by the Win key (without clicking on the Taskbar beforehand) then it can be possible to produce visible/overlapping windows. If you have produced such a window, even clicking on the Taskbar seems to work in this respect again.

(You can always start other programs (and see them pop up in the Taskbar as tabs), but their windows are not always visible/are sometimes in the background as explained above.)
[...]
The general rule seems to be: Using keys in the first place to get to other windows brings you in a state where you can produce overlapping windows generally (even by clicking on the Taskbar) but using in first place the mouse to click on the Taskbar generally denies you such a state.

But maybe that's something else taskbar related since I think it's been there longer.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 08:37:41 AM
I've reported this against Allegro 5 (https://github.com/liballeg/allegro5/issues/877), linking back to this thread and to the 2016 thread on allegro.cc.

These days, I'll have another go at building debugging libraries and giving Forestidia and Arty a small self-contained example program.

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on January 17, 2018, 10:17:37 AM
Simon, have you tried to reproduce the crash with double initialization (opening two instances of Lix at the same time or a bit delayed)?
I've tried to catch something with a batch file and redirecting arrows (via double initialization), but it only logged the Lix crash window message. Interestingly sometimes it just closed without showing the error message window then but maybe that has to do with using a batch file with redirecting arrows.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 10:26:53 AM
Cannot repro on Linux. This script opens 3 instances of Windows Lix through Wine and 3 instances of Linux version, all within 4 seconds. I get no problems at all, and all 6 instances play music at the same time in the main menu.

Spoiler (click to show/hide)

I fixed the crash in unstable/master. Now, you should hear no audio and get an error in the main menu, but can still continue playing.

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on January 17, 2018, 10:38:43 AM
I fixed the crash in unstable/master. Now, you should hear no audio and get an error in the main menu, but can still continue playing.

Yeah, that's exactly what is happening.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 10:43:57 AM
Okay, cool, thanks for confirming. Then this partial fix will go into 0.9.9.

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: ccexplore on January 17, 2018, 11:39:40 AM
Cannot repro on Linux.

It's likely an issue in one of the Windows-specific Allegro audio drivers.  For example, I skimmed through the DirectSound driver's code (https://github.com/liballeg/allegro5/blob/c7349c716c7c63f9dd177de3d00a9928ef4c8f8b/addons/audio/dsound.cpp) and there are a fair number of "FIXME" comments, including some in the _dsound_open function that I think is used during the initial driver loading.  Not exactly a vote of confidence on the quality of the code, :-\ and could well be related to the odd behavior observed with the driver not loading under certain conditions on certain versions of Windows, if there are no other Allegro audio drivers available on Windows (not sure) to fall back to.

There is one particular (and obvious) line that is suspect, and kind of makes me wonder if delaying the loading of the Allegro audio driver may help minimize this problem's rate of occurrence, specifically if there's some way to make sure the Lix window is already displayed before trying to load audio driver.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 12:38:39 PM
Lix initialized the audio before creating the window.

I've pushed a fix to unstable/master that lazily initializes the A5 audio driver. Since the main menu wants to print whether initialization is successful, audio gets now initialized on entering main menu. The display exists by then.

I've built this for Windows and attached the exe here, too. Would love feedback from Forestidia or Arty on this. :lix-smile:
-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on January 17, 2018, 12:46:22 PM
  • Does it fix the crash and give you audio every time you run the app from the quickstart bar?
  • What happens when you change resolution or display mode during program run -- audio persists from the old window.

From my side it seems to look good. I haven't gotten the error even with the reliable seeming method.
But maybe Arty should test nevertheless, since he had it consistent.
Thanks, ccexplore.

Resolution change and display mode change seems to work fine for me. Music just runs on.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 12:57:40 PM
Quote
From my side it seems to look good. I haven't gotten the error even with the reliable seeming method.
But maybe Arty should test nevertheless, since he had it consistent.
Thanks, ccexplore.

Resolution change and display mode change seems to work fine for me. Music just runs on.

Okay, perfect, thanks for the quick feedback! I've sent a PM to Arty, waiting for feedback now. This will be wonderful information for the Allegro 5 issue on github, too.

Excellent hunch from ccexplore to reorder the initializations. Thanks a ton, that skips a lot of agonizing reduction. It should be irrelevant whether the display or sound driver exists first, but apparently it makes a difference. :lix-scared: It makes sense that the big restructuring for #222 introduced this.

ccx, was it this part of the A5 code?

Code: [Select]
/* FIXME: The window specified here is probably very wrong. NULL won't work either. */
hr = device->SetCooperativeLevel(GetForegroundWindow(), DSSCL_PRIORITY);

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 01:44:22 PM
In case Forestidia would still like to build again and produce an allegro.log file (I don't think we need it anymore, though): I've tried once again to pack debugging DLLs and LIBs, see attachment. Maybe I made a mistake earlier.

I doubt this is useful anymore because we're on a good track. I attached this merely for completeness.

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Colorful Arty on January 17, 2018, 03:03:13 PM
Yep, running the lazy audio .exe file boots up the game just fine, regardless of whether it is done from the taskbar or not. The regular .exe still won't run from the taskbar though.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 17, 2018, 03:28:29 PM
Cool! Thanks everybody for the debugging help. I'll use this lazy initialization in 0.9.9 then, and will report our findings upstream.

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on January 17, 2018, 07:01:29 PM
In case Forestidia would still like to build again and produce an allegro.log file (I don't think we need it anymore, though): I've tried once again to pack debugging DLLs and LIBs, see attachment. Maybe I made a mistake earlier.

I doubt this is useful anymore because we're on a good track. I attached this merely for completeness.

I've tried it but I needed some DLLs that are contained in a MinGW-distribution on top of that (e.g. libwinpthread-1.dll). With adding them it ran and gave me the allegro.log. (The crash window message comes from Microsoft Visual C++ Runtime Library.)
The error seems exactly there where ccexplore suspected.

Log for taskbar crash (Win 7) (I've shortened the path for the Lix root directory.):
stdio    D         file_stdio.c:109  file_stdio_fopen                 [   0.00000] opening C:\...\LixD-master\bin\allegro5.cfg r
system   W            wsystem.c:792  _al_win_safe_load_library        [   0.00000] PathFindOnPath failed to find shcore.dll
system   D            wsystem.c:788  _al_win_safe_load_library        [   0.00000] PathFindOnPath found: C:\Windows\system32\user32.dll
system   D            wsystem.c:699  load_library_at_path             [   0.00000] Calling LoadLibrary C:\Windows\system32\user32.dll
system   I            wsystem.c:702  load_library_at_path             [   0.00000] Loaded C:\Windows\system32\user32.dll
system   I             system.c:263  al_install_system                [   0.00000] Allegro version: 5.2.3
dtor     D               dtor.c:196  _al_register_destructor          [   0.00014] added dtor for timer 000214E8, func 696363E1
dtor     D               dtor.c:196  _al_register_destructor          [   0.00697] added dtor for queue 0002FB00, func 69625C77
dtor     D               dtor.c:196  _al_register_destructor          [   0.00704] added dtor for queue 0002FB80, func 69625C77
audio-dsound I           dsound.cpp:255  _dsound_open                     [   0.00707] Starting DirectSound...
audio-dsound D           dsound.cpp:264  _dsound_open                     [   0.02727] DirectSoundCreate8 succeeded
audio-dsound E           dsound.cpp:269  _dsound_open                     [   0.02733] SetCooperativeLevel failed: DSERR_INVALIDPARAM
audio    E              audio.c:23   _al_set_error                    [   0.02734] No audio driver can be used. (error code: 1)
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on January 18, 2018, 05:34:35 PM
Following Nordic Bots coverage I've fiddled around as well and yeah I can get the error in Win 7 with lix-lazy-audio.exe as well but that's really forced. Nothing compared to the normal use through the taskbar which seems to be basically fine now. It's just an inherent bug in Allegro 5 that can always hit.

Edit: To be clear with crash I've meant error not really crash, I've just meant the error message in Lix, sorry.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on January 18, 2018, 07:45:18 PM
Just an unnecessary addition:

I've never tried to double initialize with the task bar. I used two executables or link and exe and pressed Enter on one and quickly double clicked on the other afterwards. (Maybe like here (https://github.com/liballeg/allegro5/issues/877#issuecomment-358723924) said it's just that double clicking focuses the window where you double click but I don't know.)

If you click on an active taskbar icon which has a window in the foreground then it usually minimizes rather than activating multiple times (at least as far as I encountered). (If I fast click while initializing I usually don't get the minimizing, maybe because the window has to initialize or something like that. It actually can behave a bit odd in this case.) But in the end it just seems like another way to force it.
You can force the error with double clicking on the taskbar icon with precise timing. The opening of the window looks in most cases regular. (If I'm a tiny bit off I think then I sometimes get the small menu I usually get when I right click on the icon without right clicking but I don't get the error usually in this case.)

Edit: I can force it as well when pressing Enter on lix.exe and then starting quickly another program from taskbar. Mere clicking on the taskbar itself (without launching a program) works as well but is much more fiddly.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 19, 2018, 01:39:22 AM
Thanks for the good tests! This is all in line with the theory that the reordered initialization in Lix helps, especially for running one instance, but remains a workaround around the A5 issue in the end.

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on January 20, 2018, 10:22:17 PM
I've mentioned Forestidia and ccexplore (https://github.com/liballeg/allegro5/issues/877#issuecomment-359206466) for their excellent debugging.

-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on February 05, 2018, 04:30:45 AM
SiegeLord has a potential fix, but needs testing on Windows.

Forestidia, do you still have your setup with the debugging DLLs?
Others:
-- Simon
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on February 05, 2018, 02:22:30 PM
My short tests couldn't produce a crash (what doesn't exclude that there can be still problems).
Attached an allegro.log with the new DLLs (Win 7).
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Forestidia86 on February 05, 2018, 07:22:33 PM
Attached an allegro.log with [   0.03672] Foreground window 00000000 which occured under conditions that would have led to a crash before but it didn't crash and played music.
Title: Re: Access Violation Error in Allegro 5 audio init
Post by: Simon on February 05, 2018, 07:47:48 PM
Wow, perfect! Will forward the second file, too.

-- Simon