Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Child window with ALLEGRO_MENU causes crash upon open/close display. #1381

Closed
MatiasMunk opened this issue Oct 28, 2022 · 2 comments · Fixed by #1467
Closed

Child window with ALLEGRO_MENU causes crash upon open/close display. #1381

MatiasMunk opened this issue Oct 28, 2022 · 2 comments · Fixed by #1467
Milestone

Comments

@MatiasMunk
Copy link

MatiasMunk commented Oct 28, 2022

Using the ex_menu.c example in a program.
The program will crash, if you open/close the child window multiple times.

This is a problem, since I'm developing a game where you can open editor windows for e.g. maps, items, etc.

Crash upon close is in 'allegro5/platform/aintwthr.h' line 59

AL_INLINE(void, _al_mutex_lock, (struct _AL_MUTEX *m),
{
   if (m->cs)
      EnterCriticalSection(m->cs);
})

Crash upon open is in 'allegro/src/win/wwindow.c' line 196
GetWindowInfo(my_window, &wi);
and sometimes other places, like allegro/src/memory.c line 44

/* Function: al_malloc_with_context
 */
void *al_malloc_with_context(size_t n,
   int line, const char *file, const char *func)
{
   if (mem)
      return mem->mi_malloc(n, line, file, func);
   else
      return malloc(n); //This right here line 44
}
@MatiasMunk MatiasMunk changed the title ALLEGRO_MENU bug Child window with ALLEGRO_MENU causes crash upon open/close display. Oct 28, 2022
@rmbeer
Copy link
Contributor

rmbeer commented Oct 28, 2022

I hope I'm not wrong.

For work with the menu in the Windows system, a ./addons/native_dialog/win_menu.c is needed.

I can't work with Windows so I can't check either.

EDIT: You have to ask for a new feature, I guess.

@MatiasMunk
Copy link
Author

MatiasMunk commented Oct 29, 2022

win_menu.c is non-existant in the source.
It's not that menu doesn't work. It does. It's just that the program crashes when you close and open the window again. I suspect some mutex lock mistake or forgetting to release some memory. Idk.

@SiegeLord SiegeLord added this to the 5.2.9 milestone Nov 7, 2022
SiegeLord pushed a commit to SiegeLord/allegro5 that referenced this issue Sep 11, 2023
Before, we'd spawn bespoke threads every 50ms. One issue with this design was that
destroying a display before that 50ms elapsed caused crashes, which happened in the menu code.

The new code has a persistent thread that periodically sends those resize events. More
importantly, we make sure that thread is aware of displays being destroyed.

Fixes liballeg#1381
SiegeLord pushed a commit that referenced this issue Sep 17, 2023
Before, we'd spawn bespoke threads every 50ms. One issue with this design was that
destroying a display before that 50ms elapsed caused crashes, which happened in the menu code.

The new code has a persistent thread that periodically sends those resize events. More
importantly, we make sure that thread is aware of displays being destroyed.

Fixes #1381
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants