Re: GtkD crash: 'BadAlloc (insufficient resources for operation)'

2020-04-28 Thread Cogitri via Digitalmars-d-learn

On Monday, 27 April 2020 at 14:53:06 UTC, mark wrote:

Below is the bt. Does it look like my bug or a Gtk or GtkD bug?


That's hard to say without the debug info for gtkd, gtk and glib 
installed (so the backtrace isn't all the useful), but since gtkd 
isn't mentioned in the log I guess that it's something in the 
interaction of gdk and X11. I guess it'd be best to ask the GTK 
folks about this.


Re: GtkD crash: 'BadAlloc (insufficient resources for operation)'

2020-04-27 Thread mark via Digitalmars-d-learn

I took Adam's advice about .gdbinit and now it runs in gdb.

When I ran the program I did Find 'memoize' which worked. Then 
'memoize python' which also worked. Then said to find 'any word' 
(which produces 1000s of rows) at which point it crashed. Below 
is the bt. Does it look like my bug or a Gtk or GtkD bug?


$ gdb DebFind
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
[snip]
Reading symbols from DebFind...done.
(gdb) run
Starting program: /home/mark/app/d/debfind/DebFind
[Thread debugging using libthread_db enabled]
Using host libthread_db library 
"/lib/x86_64-linux-gnu/libthread_db.so.1".

[New Thread 0x7fffeddfc700 (LWP 2441)]
[New Thread 0x7fffed5fb700 (LWP 2442)]
[New Thread 0x7fffe7fff700 (LWP 2443)]
[New Thread 0x77fe2700 (LWP 2444)]
[New Thread 0x77fdc700 (LWP 2445)]
[New Thread 0x77fd6700 (LWP 2446)]
[New Thread 0x77e64700 (LWP 2447)]
[New Thread 0x77e5e700 (LWP 2448)]
[New Thread 0x77e58700 (LWP 2449)]
[New Thread 0x77e52700 (LWP 2450)]
warning: Corrupted shared library list: 0x560a5e60 != 
0x55dabe00

[New Thread 0x7fffc20ff700 (LWP 2451)]
[New Thread 0x7fffc18fe700 (LWP 2452)]
[Thread 0x7fffe7fff700 (LWP 2443) exited]
[Thread 0x7fffc18fe700 (LWP 2452) exited]
populateNames
populateNames
populateNames

(DebFind:2436): Gdk-ERROR **: 15:48:40.080: The program 'DebFind' 
received an X Window System error.

This probably reflects a bug in the program.
The error was 'BadAlloc (insufficient resources for operation)'.
  (Details: serial 12790 error_code 11 request_code 130 (MIT-SHM) 
minor_code 5)
  (Note to programmers: normally, X errors are reported 
asynchronously;

   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE 
environment

   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() 
function.)


Thread 1 "DebFind" received signal SIGTRAP, Trace/breakpoint trap.
0x766c3ea1 in ?? () from 
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0

(gdb) bt
#0  0x766c3ea1 in  () at 
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#1  0x766c6819 in g_log_writer_default () at 
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x766c4a8e in g_log_structured_array () at 
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x766c54ce in g_log_structured_standard () at 
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x75f62c41 in  () at 
/usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#5  0x75f6fac3 in  () at 
/usr/lib/x86_64-linux-gnu/libgdk-3.so.0
warning: (Internal error: pc 0x5579a2d4 in read in psymtab, 
but not in symtab.)


warning: (Internal error: pc 0x5579a280 in read in psymtab, 
but not in symtab.)


warning: (Internal error: pc 0x5579a2d4 in read in psymtab, 
but not in symtab.)


#6  0x737138fa in _XError () at 
/usr/lib/x86_64-linux-gnu/libX11.so.6
warning: (Internal error: pc 0x5579a2d4 in read in psymtab, 
but not in symtab.)


#7  0x7371082b in  () at 
/usr/lib/x86_64-linux-gnu/libX11.so.6
#8  0x737108d5 in  () at 
/usr/lib/x86_64-linux-gnu/libX11.so.6
#9  0x73711205 in _XEventsQueued () at 
/usr/lib/x86_64-linux-gnu/libX11.so.6
#10 0x73702d3d in XPending () at 
/usr/lib/x86_64-linux-gnu/libX11.so.6
#11 0x75f6a09e in  () at 
/usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#12 0x766bdb28 in g_main_context_prepare () at 
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#13 0x766be4fb in  () at 
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
warning: (Internal error: pc 0x5579a2d4 in read in psymtab, 
but not in symtab.)


#14 0x766be6dc in g_main_context_iteration () at 
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
warning: (Internal error: pc 0x5579a2d4 in read in psymtab, 
but not in symtab.)


#15 0x7537eefd in g_application_run () at 
/usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
warning: (Internal error: pc 0x5579a2d4 in read in psymtab, 
but not in symtab.)


#16 0x5579a2d5 in warning: (Internal error: pc 
0x5579a2d4 in read in psymtab, but not in symtab.)


_D3gio11ApplicationQn3runMFAAyaZiwarning: (Internal error: pc 
0x5579a2d4 in read in psymtab, but not in symtab.)


warning: (Internal error: pc 0x5579a2d4 in read in psymtab, 
but not in symtab.)


 (warning: (Internal error: pc 0x5579a2d4 in read in psymtab, 
but not in symtab.)


this=0x77ed0360, warning: (Internal error: pc 0x5579a2d4 
in read in psymtab, but not in symtab.)


argv=...)warning: (Internal error: pc 0x5579a2d4 in read in 
psymtab, but not in symtab.)


 at Application.dwarning: (Internal error: pc 0x5579a2d4 in 
read in psymtab, but not in symtab.)


warning: (Internal error: pc 0x5579a2d4 in read in psymtab, 
but not in symtab.)


:931
#17 0x55784380 in D main (args=...) at app.d:18



Re: GtkD crash: 'BadAlloc (insufficient resources for operation)'

2020-04-27 Thread Cogitri via Digitalmars-d-learn

Hello,

could you try what the error message suggest you to do:

On Monday, 27 April 2020 at 12:03:18 UTC, mark wrote:
  (Note to programmers: normally, X errors are reported 
asynchronously;

   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE 
environment
   variable to change this behavior. You can then get a 
meaningful
   backtrace from your debugger if you break on the 
gdk_x_error() function.)

Program exited with code -5


With that you should be able to run your program in gdb and get a 
backtrace.
However, BadAlloc sounds to me as if your program is running out 
of RAM and as such can't allocate more memory.


GtkD crash: 'BadAlloc (insufficient resources for operation)'

2020-04-27 Thread mark via Digitalmars-d-learn
I'm getting a crash when I add 1000s of rows to a tree (up to 
100s seems to work ok).


The source code is here: 
https://github.com/mark-summerfield/debfind
Note that this will only build and run on a Debian or 
Debian-derived system (e.g., Ubuntu).


I am pretty well reaching the point of giving up with GtkD -- and 
therefore with GUI programming in D since there isn't really a 
decent reliable D GUI library that I can find. (I don't want to 
use Qt or QML because of the licensing issues.)



(DebFind:3285): Gdk-ERROR **: 12:59:59.299: The program 'DebFind' 
received an X Window System error.

This probably reflects a bug in the program.
The error was 'BadAlloc (insufficient resources for operation)'.
  (Details: serial 25818 error_code 11 request_code 130 (MIT-SHM) 
minor_code 5)
  (Note to programmers: normally, X errors are reported 
asynchronously;

   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE 
environment

   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() 
function.)

Program exited with code -5



Re: GtkD crash

2020-02-22 Thread Ron Tarrant via Digitalmars-d-learn

On Friday, 21 February 2020 at 13:36:58 UTC, mark wrote:

I thought that onChangeState was never called before the Label 
was constructed


That's one of the 'features' (wink wink) of GtkD. It's possible 
to call the function as a class function (uninstantiated, in 
other words) or as an object function (instantiated). There are 
times when it's handy to have either at your disposal.



Now it works.

Thanks!





Re: GtkD crash

2020-02-21 Thread mark via Digitalmars-d-learn
Thanks for your question, it led me to focus on the Label and now 
I've solved the problem.


I thought that onChangeState was never called before the Label 
was constructed, but it turns out it is called before. So now I 
use:


if (statusLabel !is null)
statusLabel.setText(message);

Now it works.

Thanks!


Re: GtkD crash

2020-02-21 Thread Ron Tarrant via Digitalmars-d-learn

On Friday, 21 February 2020 at 08:55:43 UTC, mark wrote:


statusLabel.setText(message); // BUG


Where is statusLabel instantiated?

Other than that, I see nothing wrong here.



GtkD crash

2020-02-21 Thread mark via Digitalmars-d-learn
I'm porting a simple game to GtkD to learn the library and more 
about D.


Unfortunately, I've hit a show-stopping crash.

I have a subclass of ApplicationWindow which has this method:

private void onChangeState(int score, Board.State state) {
import std.format: format;

string message;
if (state == Board.State.GAME_OVER)
message = format("%,d Game Over", score);
else if (state == Board.State.USER_WON) {
if (score > highScore) {
message = format("%,d New High Score!", score);
highScore = score; // TODO save highScore
} else
message = format("%,d You Won!", score);
} else // still playing
message = format("%,d/%,d", score, highScore);
statusLabel.setText(message); // BUG
}

This method gets passed to another widget which calls it whenever 
the game's state or score changes.


If the BUG line is commented out, the program runs fine (well, 
except that the Label always shows "0/0").


But if the BUG line is uncommented (as above), it crashes:

$ dub
Performing "debug" build using 
/home/mark/opt/ldc2-1.20.0-linux-x86_64/bin/ldc2 for x86_64.
gtk-d:gtkd 3.9.0: target for configuration "library" is up to 
date.
gravitate ~master: target for configuration "application" is up 
to date.

To force a rebuild of up-to-date targets, run again with --force.
Running ./gravitate
onChangeState 0 PLAYING
Program exited with code -11

Here's what it looks like in gdb (slightly edited):

$ gdb gravitate
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
[snip]
This GDB was configured as "x86_64-linux-gnu".
[snip]
Reading symbols from gravitate...done.
(gdb) run
Starting program: /home/mark/app/gravitate/d/gravitate
[Thread debugging using libthread_db enabled]
Using host libthread_db library 
"/lib/x86_64-linux-gnu/libthread_db.so.1".

[New Thread 0x76e02700 (LWP 7017)]
[New Thread 0x76601700 (LWP 7018)]
[New Thread 0x75e00700 (LWP 7019)]
[New Thread 0x755ff700 (LWP 7020)]
[New Thread 0x74dfe700 (LWP 7021)]
[New Thread 0x7fffd700 (LWP 7022)]
[New Thread 0x7fffdf7fe700 (LWP 7023)]
[New Thread 0x7fffce3a5700 (LWP 7024)]
[New Thread 0x7fffcdba4700 (LWP 7025)]
onChangeState 0 PLAYING

Thread 1 "gravitate" received signal SIGSEGV, Segmentation fault.
0x55704cc1 in gamewindow.GameWindow.onChangeState(int, 
board.Board.State) (this=0x77ecf700, score=0,

state=board.Board.PLAYING) at gamewindow.d:182
182 statusLabel.setText(message);
(gdb) bt
warning: (Internal error: pc 0x55703fbf in read in psymtab, 
but not in symtab.)
warning: (Internal error: pc 0x55703fbf in read in psymtab, 
but not in symtab.)

[ + several more like these ]

#0  0x55704cc1 in 
gamewindow.GameWindow.onChangeState(int, board.Board.State) 
(this=0x77ecf700, score=0, state=board.Board.PLAYING) at 
gamewindow.d:182
warning: (Internal error: pc 0x55703fbf in read in psymtab, 
but not in symtab.)
#1  0x55728246 in board.Board.newGame() 
(this=0x7fffcc92d000) at board.d:60
warning: (Internal error: pc 0x55703fbf in read in psymtab, 
but not in symtab.)
warning: (Internal error: pc 0x55703a2b in read in psymtab, 
but not in symtab.)
#2  0x55704bb8 in 
_D5board5Board6__ctorMFDFiEQzQv5StateZvZCQBnQBk (warning: 
(Internal error: pc 0x55703fbf in read in psymtab, but not in 
symtab.)
this=0x7fffcc92d000, warning: (Internal error: pc 0x55703fbf 
in read in psymtab, but not in symtab.)

onChangeState=...)
at board.d:42
warning: (Internal error: pc 0x55703fbf in read in psymtab, 
but not in symtab.)
warning: (Internal error: pc 0x55703a2b in read in psymtab, 
but not in symtab.)
#3  0x55703fc0 in warning: (Internal error: pc 
0x55703fbf in read in psymtab, but not in symtab.)
gamewindow.GameWindow.makeWidgets()warning: (Internal error: pc 
0x55703fbf in read in psymtab, but not in symtab.)
warning: (Internal error: pc 0x55703fbf in read in psymtab, 
but not in symtab.)
 (warning: (Internal error: pc 0x55703fbf in read in psymtab, 
but not in symtab.)
warning: (Internal error: pc 0x55703a2b in read in psymtab, 
but not in symtab.)
this=0x77ecf700)warning: (Internal error: pc 0x55703fbf 
in read in psymtab, but not in symtab.)
 at gamewindow.dwarning: (Internal error: pc 0x55703fbf in 
read in psymtab, but not in symtab.)
warning: (Internal error: pc 0x55703fbf in read in psymtab, 
but not in symtab.)

:58
warning: (Internal error: pc 0x55703a2b in read in psymtab, 
but not in symtab.)
#4  0x55703a2c in warning: (Internal error: pc 
0x55703a2b in read in psymtab, but not in symtab.)

_D10gamewindow10GameWindow6__ctorMFC3gtk11ApplicationQnZCQCdQBuwarning: 
(Internal error: pc 0x55703a2b in read in psymtab, but not in symtab.)
warning: (Internal error: pc 0x55703a2b in read in psymtab, 
but not in symtab.)
 (warning: (Internal error: pc