www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - [SDL + TKD] Seg fault from creating DirectoryDialog

reply "Jack" <Jackoz530 gmail.com> writes:
Well, to start, I'm trying to create a mp3 player for 
"educational purposes".
I'm using DerelictSDL(SDL_MIXER) as a library for the backend and 
TKD for the GUI.

I have two objects to represent the two. The constructor for the 
sdl one contains the syntax for loading the DerelictSDL 
modules(DerelictSDL2.load()) and to initialize the SDL library 
(SDL_Init(SDL_INIT_EVERYTHING)), and the constructor for the TKD 
application initializes the sdl object.

// constructor for tkd
this() {
Sdl sdl = new Sdl();
}

//constructor for sdl
this(){
DerelictSDL2.load();
/*etc...*/
//

and I set a command function to a button that creates the 
DirectoryDialog.

at least, that's what it was supposed to do.

Whole error is: http://codepad.org/C2l4rUel

and gdb spews out a segmentation fault error:
http://codepad.org/X6CqH3vK
That, I think, revealed a threading conflict between the two 
libraries.

Can anybody with enough knowledge point me to the right 
direction? or just confirm what I have?
Nov 02 2014
parent reply "Gary Willoughby" <dev nomad.so> writes:
On Sunday, 2 November 2014 at 12:11:23 UTC, Jack wrote:
 Whole error is: http://codepad.org/C2l4rUel
That's not the true error. That's dub throwing an exception when trying to run the built executable. As shown here: https://github.com/D-Programming-Language/dub/blob/master/source%2Fdub%2Fgenerators%2Fbuild.d#L464 I would suggest building the application without using dub then run the program through a debugger to find the location in the source where it's actually seg-faulting. I personally use this one: http://www.affinic.com/?page_id=109.
Nov 02 2014
parent reply "Jack" <Jackoz530 gmail.com> writes:
On Sunday, 2 November 2014 at 17:39:46 UTC, Gary Willoughby wrote:
 On Sunday, 2 November 2014 at 12:11:23 UTC, Jack wrote:
 Whole error is: http://codepad.org/C2l4rUel
That's not the true error. That's dub throwing an exception when trying to run the built executable. As shown here: https://github.com/D-Programming-Language/dub/blob/master/source%2Fdub%2Fgenerators%2Fbuild.d#L464 I would suggest building the application without using dub then run the program through a debugger to find the location in the source where it's actually seg-faulting. I personally use this one: http://www.affinic.com/?page_id=109.
Thank you. I built the program using the compiler and debugged it with the C::B gui version of gdb, and it spewed out information about call stacks and things that, I confess, I have no idea what the hell it is: http://codepad.org/Bj3y6tqr and it seems to point to line 123 in tcl.d as shown here: http://picpaste.com/pics/Screenshot_from_2014-11-03_06_53_17-C6eIWp7k.1414969454.png And now, as I said before, don't know what this is exactly.
Nov 02 2014
parent reply "Gary Willoughby" <dev nomad.so> writes:
On Sunday, 2 November 2014 at 23:05:05 UTC, Jack wrote:
 On Sunday, 2 November 2014 at 17:39:46 UTC, Gary Willoughby 
 wrote:
 On Sunday, 2 November 2014 at 12:11:23 UTC, Jack wrote:
 Whole error is: http://codepad.org/C2l4rUel
That's not the true error. That's dub throwing an exception when trying to run the built executable. As shown here: https://github.com/D-Programming-Language/dub/blob/master/source%2Fdub%2Fgenerators%2Fbuild.d#L464 I would suggest building the application without using dub then run the program through a debugger to find the location in the source where it's actually seg-faulting. I personally use this one: http://www.affinic.com/?page_id=109.
Thank you. I built the program using the compiler and debugged it with the C::B gui version of gdb, and it spewed out information about call stacks and things that, I confess, I have no idea what the hell it is: http://codepad.org/Bj3y6tqr and it seems to point to line 123 in tcl.d as shown here: http://picpaste.com/pics/Screenshot_from_2014-11-03_06_53_17-C6eIWp7k.1414969454.png And now, as I said before, don't know what this is exactly.
Looks like a threading error somewhere. What version of Tcl/Tk are you linking against? Are you using threads in your program? Tcl/Tk can be a pain with threading as i've read. There exists thread-friendly versions as seen here: http://www.tcl.tk/doc/howto/compile.html Notice the --enable-threads switch. I don't really know what to suggest. Try reducing the program down until you've found where the issue stops happening. It may be an incompatibility with SDL?
Nov 03 2014
parent reply "Jack" <Jackoz530 gmail.com> writes:
On Monday, 3 November 2014 at 14:32:07 UTC, Gary Willoughby wrote:
 On Sunday, 2 November 2014 at 23:05:05 UTC, Jack wrote:
 On Sunday, 2 November 2014 at 17:39:46 UTC, Gary Willoughby 
 wrote:
 On Sunday, 2 November 2014 at 12:11:23 UTC, Jack wrote:
 Whole error is: http://codepad.org/C2l4rUel
That's not the true error. That's dub throwing an exception when trying to run the built executable. As shown here: https://github.com/D-Programming-Language/dub/blob/master/source%2Fdub%2Fgenerators%2Fbuild.d#L464 I would suggest building the application without using dub then run the program through a debugger to find the location in the source where it's actually seg-faulting. I personally use this one: http://www.affinic.com/?page_id=109.
Thank you. I built the program using the compiler and debugged it with the C::B gui version of gdb, and it spewed out information about call stacks and things that, I confess, I have no idea what the hell it is: http://codepad.org/Bj3y6tqr and it seems to point to line 123 in tcl.d as shown here: http://picpaste.com/pics/Screenshot_from_2014-11-03_06_53_17-C6eIWp7k.1414969454.png And now, as I said before, don't know what this is exactly.
Looks like a threading error somewhere. What version of Tcl/Tk are you linking against? Are you using threads in your program? Tcl/Tk can be a pain with threading as i've read. There exists thread-friendly versions as seen here: http://www.tcl.tk/doc/howto/compile.html Notice the --enable-threads switch. I don't really know what to suggest. Try reducing the program down until you've found where the issue stops happening. It may be an incompatibility with SDL?
I'm linking the tcl 8.63 version and no I'm not using threads. I tested removing the SDL part of the code and built it and there were no threading issues. Maybe it is as you say an incompatibility with SDL I'll try and think about this for a while Thanks for the help sir.
Nov 03 2014
parent reply "Gary Willoughby" <dev nomad.so> writes:
On Monday, 3 November 2014 at 22:26:14 UTC, Jack wrote:
 I'll try and think about this for a while
 Thanks for the help sir.
No worries. I don't really know what else to suggest without seeing a little code. Do you have a simple full program that shows the error happening?
Nov 04 2014
parent reply "Jack" <Jackoz530 gmail.com> writes:
On Tuesday, 4 November 2014 at 08:30:34 UTC, Gary Willoughby
wrote:
 On Monday, 3 November 2014 at 22:26:14 UTC, Jack wrote:
 I'll try and think about this for a while
 Thanks for the help sir.
No worries. I don't really know what else to suggest without seeing a little code. Do you have a simple full program that shows the error happening?
Here's the main file: http://codepad.org/hu4r0ExB and Here's the module: http://codepad.org/ikXAzfdg Dependencies are DerelictSDL and Tkd. It's the most simple one I got that reproduces the error.
Nov 04 2014
next sibling parent Mike Parker <aldacron gmail.com> writes:
On 11/4/2014 7:34 PM, Jack wrote:
 On Tuesday, 4 November 2014 at 08:30:34 UTC, Gary Willoughby
 Here's the main file:
 http://codepad.org/hu4r0ExB

 and Here's the module:
 http://codepad.org/ikXAzfdg

 Dependencies are DerelictSDL and Tkd.

 It's the most simple one I got that reproduces the error.
You might start by adding a call to Mix_Init after SDL_Init and before calling any other Mix_* functions. SDL_Init doesn't know anything about the SDL_mixer library. See [1] for details (and don't forget the corresponding Mix_Quit [2]). [1] https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_9.html [2] https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_10.html#SEC10
Nov 04 2014
prev sibling next sibling parent reply "Gary Willoughby" <dev nomad.so> writes:
On Tuesday, 4 November 2014 at 10:34:19 UTC, Jack wrote:
 No worries. I don't really know what else to suggest without 
 seeing a little code. Do you have a simple full program that 
 shows the error happening?
Here's the main file: http://codepad.org/hu4r0ExB and Here's the module: http://codepad.org/ikXAzfdg Dependencies are DerelictSDL and Tkd. It's the most simple one I got that reproduces the error.
Have you got a copy of the dub.json file you use?
Nov 04 2014
parent "Gary Willoughby" <dev nomad.so> writes:
On Tuesday, 4 November 2014 at 18:22:49 UTC, Gary Willoughby 
wrote:
 On Tuesday, 4 November 2014 at 10:34:19 UTC, Jack wrote:
 No worries. I don't really know what else to suggest without 
 seeing a little code. Do you have a simple full program that 
 shows the error happening?
Here's the main file: http://codepad.org/hu4r0ExB and Here's the module: http://codepad.org/ikXAzfdg Dependencies are DerelictSDL and Tkd. It's the most simple one I got that reproduces the error.
Have you got a copy of the dub.json file you use?
Ah, no matter, i've got all the libs installed and linking now.
Nov 04 2014
prev sibling parent reply "Gary Willoughby" <dev nomad.so> writes:
On Tuesday, 4 November 2014 at 10:34:19 UTC, Jack wrote:
 Here's the main file:
 http://codepad.org/hu4r0ExB

 and Here's the module:
 http://codepad.org/ikXAzfdg

 Dependencies are DerelictSDL and Tkd.

 It's the most simple one I got that reproduces the error.
If you change the way SDL is initialised it works. Instead of doing: SDL_Init(SDL_INIT_EVERYTHING); do: SDL_Init(0); SDL_InitSubSystem(SDL_INIT_TIMER); SDL_InitSubSystem(SDL_INIT_AUDIO); SDL_InitSubSystem(SDL_INIT_JOYSTICK); SDL_InitSubSystem(SDL_INIT_HAPTIC); SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER); SDL_InitSubSystem(SDL_INIT_EVENTS); Initialising the following exhibits the crash. // SDL_InitSubSystem(SDL_INIT_VIDEO); So there must be an incompatibility with the video subsystem and tcl/tk.
Nov 04 2014
parent reply "Jack" <Jackoz530 gmail.com> writes:
On Tuesday, 4 November 2014 at 18:53:33 UTC, Gary Willoughby 
wrote:
 On Tuesday, 4 November 2014 at 10:34:19 UTC, Jack wrote:
 Here's the main file:
 http://codepad.org/hu4r0ExB

 and Here's the module:
 http://codepad.org/ikXAzfdg

 Dependencies are DerelictSDL and Tkd.

 It's the most simple one I got that reproduces the error.
If you change the way SDL is initialised it works. Instead of doing: SDL_Init(SDL_INIT_EVERYTHING); do: SDL_Init(0); SDL_InitSubSystem(SDL_INIT_TIMER); SDL_InitSubSystem(SDL_INIT_AUDIO); SDL_InitSubSystem(SDL_INIT_JOYSTICK); SDL_InitSubSystem(SDL_INIT_HAPTIC); SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER); SDL_InitSubSystem(SDL_INIT_EVENTS); Initialising the following exhibits the crash. // SDL_InitSubSystem(SDL_INIT_VIDEO); So there must be an incompatibility with the video subsystem and tcl/tk.
So it seems. Thank you very much for helping me. You were a big help.
Nov 04 2014
parent "Gary Willoughby" <dev nomad.so> writes:
On Tuesday, 4 November 2014 at 23:09:33 UTC, Jack wrote:
 So there must be an incompatibility with the video subsystem 
 and tcl/tk.
So it seems. Thank you very much for helping me. You were a big help.
Sorry i can't do more. I'm the author of Tkd and would like to get to the bottom of it.
Nov 05 2014