autotrace / autotrace

bitmap to vector graphics converter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

g_hash_table_lookup: assertion 'hash_table != NULL' failed

WillNilges opened this issue · comments

When using autotrace in my project, I get SEGFAULTs when the library is trying to figure out what kind of file I have. I seem to be following what main.c is doing pretty much 1:1, but for whatever reason, on v0.40.0 (well, actually it's from a fork, I get this error. Of course, the command line works fine.

g_hash_table_lookup: assertion 'hash_table != NULL' failed

Here's the full stacktrace:

We're using /mnt/geriatrics/data/that_one_2018_pic_cv.png.                                                                                                                                                                                     
                                                                                                                                                                                                                                               
(xournalpp:6848): GLib-CRITICAL **: 05:41:49.119: g_hash_table_lookup: assertion 'hash_table != NULL' failed                                                                                                                                   
                                                                                                                                                                                                                                               
Thread 1 "xournalpp" received signal SIGSEGV, Segmentation fault.                                                                                                                                                                              
0x00007f4fcb73af70 in at_bitmap_read (reader=0x0, filename=0x5612576d0278 "/mnt/geriatrics/data/that_one_2018_pic_cv.png", opts=0x0, msg_func=0x0, msg_data=0x0)                                                                               
    at src/autotrace.c:132                                                                                                                                                                                                                     
132       *bitmap = (*reader->func) (filename, opts, msg_func, msg_data, reader->data);                                                                                                                                                        
(gdb) backtrace                                                                                                                                                                                                                                
#0  0x00007f4fcb73af70 in at_bitmap_read (reader=0x0, filename=0x5612576d0278 "/mnt/geriatrics/data/that_one_2018_pic_cv.png", opts=0x0, msg_func=0x0, msg_data=0x0)                                                                           
    at src/autotrace.c:132                                                                                                                                                                                                                     
#1  0x00007f4fd14dc36d in transcribe_image (L=0x561256e79f48) at src/lua_util.c:39                                                                                                                                                             
#2  0x00007f4fd62f4585 in  () at /usr/lib/x86_64-linux-gnu/liblua5.3.so.0                                                                                                                                                                      
#3  0x00007f4fd6301355 in  () at /usr/lib/x86_64-linux-gnu/liblua5.3.so.0                                                                                                                                                                      
#4  0x00007f4fd62f4998 in  () at /usr/lib/x86_64-linux-gnu/liblua5.3.so.0                                                                                                                                                                      
#5  0x00007f4fd62f49c1 in  () at /usr/lib/x86_64-linux-gnu/liblua5.3.so.0                                                                                                                                                                      
#6  0x00007f4fd62f3d82 in  () at /usr/lib/x86_64-linux-gnu/liblua5.3.so.0                                                                                                                                                                      
#7  0x00007f4fd62f4c4b in  () at /usr/lib/x86_64-linux-gnu/liblua5.3.so.0                                              
#8  0x00007f4fd62f0594 in lua_pcallk () at /usr/lib/x86_64-linux-gnu/liblua5.3.so.0                                    
#9  0x0000561255df3bea in Plugin::callFunction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (this=0x561256f04600, fnc="drawStroke")                                                                 
    at /root/devtop/Code/xournalpp/src/plugin/Plugin.cpp:246                                                           
#10 0x0000561255df2e4d in Plugin::executeMenuEntry(MenuEntry*) (this=0x561256f04600, entry=0x561256e2d150) at /root/devtop/Code/xournalpp/src/plugin/Plugin.cpp:91                                                                             
#11 0x0000561255df2bd3 in operator()(GtkWidget*, MenuEntry*) const (__closure=0x0, bt=0x561257236a70, me=0x561256e2d150) at /root/devtop/Code/xournalpp/src/plugin/Plugin.cpp:84                                                               
#12 0x0000561255df2bfb in _FUN(GtkWidget*, MenuEntry*) () at /root/devtop/Code/xournalpp/src/plugin/Plugin.cpp:84                                                                                                                              
#13 0x00007f4fd66690a2 in g_closure_invoke () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0                                                                                                                                                 
#14 0x00007f4fd667b413 in  () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0                                         
#15 0x00007f4fd66816cf in g_signal_emit_valist () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0                                                                                                                                             
#16 0x00007f4fd6681c3f in g_signal_emit () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0                                                                                                                                                    
#17 0x00007f4fd6edc354 in gtk_widget_activate () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0                                                                                                                                                    
#18 0x00007f4fd6da2456 in gtk_menu_shell_activate_item () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0                                                                                                                                           
#19 0x00007f4fd6da2733 in  () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0                                               
#20 0x00007f4fd6f2f9f8 in  () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0                                               
#21 0x00007f4fd66692ee in  () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0                                         
#22 0x00007f4fd6680df9 in g_signal_emit_valist () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0                                                                                                                                             
#23 0x00007f4fd6681c3f in g_signal_emit () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0                                                                                                                                                    
#24 0x00007f4fd6ed9d04 in  () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0                                               
#25 0x00007f4fd6d8ce00 in  () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0                                               
#26 0x00007f4fd6d8ea63 in gtk_main_do_event () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0                              
#27 0x00007f4fd6a77785 in  () at /usr/lib/x86_64-linux-gnu/libgdk-3.so.0                                               
#28 0x00007f4fd6aab2e2 in  () at /usr/lib/x86_64-linux-gnu/libgdk-3.so.0                                               
#29 0x00007f4fd7345e6b in g_main_context_dispatch () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0                                                                                                                                             
#30 0x00007f4fd7346118 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0                                            
#31 0x00007f4fd73461cf in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0                                                                                                                                            
#32 0x00007f4fd678e545 in g_application_run () at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0                                                                                                                                                    
#33 0x0000561255ca50e0 in XournalMain::run(int, char**) (argc=1, argv=0x7ffef70ee948) at /root/devtop/Code/xournalpp/src/control/XournalMain.cpp:695                                                                                           
#34 0x0000561255c672da in main(int, char**) (argc=1, argv=0x7ffef70ee948) at /root/devtop/Code/xournalpp/src/Xournalpp.cpp:41

Problem seems to be that the hashtable lookup on the .png extension is broken, though I swear that this is compiled with libpng support.

This also wasn't an issue on Fedora when using autotrace 0.31. My code worked fine.

I've been drilling down into this lookup functionality to see if I can pinpoint the issue, but the workaround I'm considering employing for now is to just... pass .png as an argument. Though, I'd like to be able to support a variety of image formats with my project.

(Here's my code: https://github.com/WillNilges/inkpath/blob/ceb6647a8260420f9e6e4fb0fe4a3b16bdc5abd8/src/lua_util.c)

Seems like the table isn't getting loaded.

150       format = g_hash_table_lookup(at_input_formats, gsuffix);
(gdb) print at_input_formats
$1 = 0x0
(gdb) print gsuffix
$2 = (gchar *) 0x555ca952b8f0 "png"
(gdb) 

If I GDB autotrace called from the command line, it's present.

Breakpoint 2, at_input_get_handler_by_suffix (suffix=<optimized out>) at src/input.c:150
150       format = g_hash_table_lookup(at_input_formats, gsuffix);
(gdb)  print at_input_formats
Python Exception <class 'gdb.error'> There is no member named keys.: 
$3 = 0x55698eda7d80
(gdb) print gsuffix
$4 = (gchar *) 0x55698edc2210 "png"

I was thinking this might have something to do with the way I'm compiling my .so file (my project is a plugin), but I also wrote a standalone tool, and that isn't working either.

Well, now I'm not so sure.

root@boalisk:/mnt/code/inkpath/build# ./inkpath /mnt/code/data/cropped/working/input_fixed_01.png ./output.xoj
(process:10506): GLib-CRITICAL **: 21:21:55.595: g_hash_table_lookup: assertion 'hash_table != NULL' failed
Segmentation fault (core dumped)

I did write a standalone program to do the tracing that's supposed to just export directly to .xoj format, and it's also having problems, which means that it's not just a .so issue. Something might be broken with the library itself.

autotrace_init();

Y'all need some documentation.