LegalizeAdulthood / iterated-dynamics

Iterated Dynamics is an open source fractal generator with support for many fractal types.
https://legalizeadulthood.github.io/iterated-dynamics/
GNU General Public License v3.0
24 stars 9 forks source link

Segmentation Fault on linux at x11_text_window::put_string #138

Open eniac11 opened 3 days ago

eniac11 commented 3 days ago

I just built (v1.0.0) and compiled id and it compiles successfully but when I try to run it it crashes. Not sure of usability of linux port.

Anyway, I have done some debugging and it seems like when it tries to iterate over the string and set the global variable text_ it crashes. Breaking just at ::put_string and looking at text_ gdb says that its size is 0. This means that text_ does not get initialized.

I also had to change CMAKE_BUILD_TYPE=Debug as some symbols were missing, I think this should be the default in the preset.

This error also seems to be point to another issue.

EDIT: turns out that the second error was from launching it in the build directory, had to do a make package though it still crashes in a similar way just in different place.

backtrace

#0  x11_text_window::put_string (this=0x555555786fb0 <x11_driver_info+19952>, xpos=0, ypos=0, attrib=15, text="Id found the following problems when parsing commands: ", end_row=0x555555761af0 <g_text_row>, 
    end_col=0x555555761af4 <g_text_col>) at /home/eniac11/Documents/dev/projects/iterated-dynamics/unix/x11_text.cpp:830
#1  0x00005555556a5756 in X11Driver::put_string (this=0x5555557821c0 <x11_driver_info>, row=0, col=0, attr=15, msg=0x5555556be330 "Id found the following problems when parsing commands: ")
    at /home/eniac11/Documents/dev/projects/iterated-dynamics/unix/d_x11.cpp:2444
#2  0x000055555556fd21 in driver_put_string (row=0, col=0, attr=15, msg=0x5555556be330 "Id found the following problems when parsing commands: ") at /home/eniac11/Documents/dev/projects/iterated-dynamics/libid/include/drivers.h:251
#3  0x00005555555e448a in init_msg (cmdstr=0x7fffffffaa58 "map", badfilename=0x7fffffffaf34 "maps/default.map", mode=cmd_file::SSTOOLS_INI) at /home/eniac11/Documents/dev/projects/iterated-dynamics/libid/cmdfiles.cpp:4089
#4  0x00005555555e15ad in cmd_map (cmd=...) at /home/eniac11/Documents/dev/projects/iterated-dynamics/libid/cmdfiles.cpp:2455
#5  0x00005555555e952f in std::__invoke_impl<cmdarg_flags, cmdarg_flags (*&)(Command const&), Command const&> (__f=@0x55555574b1f0: 0x5555555e151a <cmd_map(Command const&)>) at /usr/include/c++/12/bits/invoke.h:61
#6  0x00005555555e8f27 in std::__invoke_r<cmdarg_flags, cmdarg_flags (*&)(Command const&), Command const&> (__fn=@0x55555574b1f0: 0x5555555e151a <cmd_map(Command const&)>) at /usr/include/c++/12/bits/invoke.h:114
#7  0x00005555555e8512 in std::_Function_handler<cmdarg_flags (Command const&), cmdarg_flags (*)(Command const&)>::_M_invoke(std::_Any_data const&, Command const&) (__functor=..., __args#0=...)
    at /usr/include/c++/12/bits/std_function.h:290
#8  0x00005555555e868d in std::function<cmdarg_flags (Command const&)>::operator()(Command const&) const (this=0x55555574b1f0 <s_commands+3472>, __args#0=...) at /usr/include/c++/12/bits/std_function.h:591
#9  0x00005555555e7e2b in handle_command<157ul> (handlers=..., cmd=...) at /home/eniac11/Documents/dev/projects/iterated-dynamics/libid/cmdfiles.cpp:3896
#10 0x00005555555e3cfb in cmdarg (curarg=0x7fffffffaf30 "map=maps/default.map", mode=cmd_file::SSTOOLS_INI) at /home/eniac11/Documents/dev/projects/iterated-dynamics/libid/cmdfiles.cpp:3926
#11 0x00005555555dd312 in cmdfile (handle=0x5555557b1ad0, mode=cmd_file::SSTOOLS_INI) at /home/eniac11/Documents/dev/projects/iterated-dynamics/libid/cmdfiles.cpp:642
#12 0x00005555555dc373 in process_sstools_ini () at /home/eniac11/Documents/dev/projects/iterated-dynamics/libid/cmdfiles.cpp:261
#13 0x00005555555dc776 in cmdfiles (argc=1, argv=0x7fffffffd8f8) at /home/eniac11/Documents/dev/projects/iterated-dynamics/libid/cmdfiles.cpp:339
#14 0x000055555556e8c2 in main_restart (argc=1, argv=0x7fffffffd8f8, stacked=@0x7fffffffd7b5: false) at /home/eniac11/Documents/dev/projects/iterated-dynamics/libid/id_main.cpp:198
#15 0x000055555556f008 in id_main (argc=1, argv=0x7fffffffd8f8) at /home/eniac11/Documents/dev/projects/iterated-dynamics/libid/id_main.cpp:516
#16 0x000055555556e629 in main (argc=1, argv=0x7fffffffd8f8) at /home/eniac11/Documents/dev/projects/iterated-dynamics/unix/main.cpp:5

locals

xc = 73 'I'
__for_range = "Id found the following problems when parsing commands: "
__for_begin = 73 'I'
__for_end = 0 '\000'
xa = 15 '\017'
maxrow = 0
j = 0
maxcol = 0
k = 0
stored = false

print of text_:

(gdb) print text_
$19 = std::vector of length 0, capacity 0

error message

Program received signal SIGSEGV, Segmentation fault.
0x00005555555f3076 in std::vector<char, std::allocator<char> >::operator[] (this=0x0, __n=0) at /usr/include/c++/12/bits/stl_vector.h:1124
1124            return *(this->_M_impl._M_start + __n);
LegalizeAdulthood commented 2 days ago

The linux port is incomplete. At the moment, it compiles and passes the unit tests and skips the image tests (since it can't properly generate an image).

The current plan is to get the linux side working completely when the switch to wxWidgets happens, because everything should be cross-platform at that point.

Earlier, the intentions was to write an X11 implementation of the driver API but then I realized that I was just duplicating a lot of functionality for the text window between Win32 and X11 and that if I wrote a wxWidgets control for the text window, then the code would be the same for both platforms and essentially the driver API could be identical across both Win32 and linux.