أحمد المحمودي <[EMAIL PROTECTED]> writes:

> Unfortunately I cannot find any *core* files after elinks crashes !

You may be able to change that with ulimit -c in bash.
However, for easily reproduceable crashes, I find it easier
to run elinks within gdb, because that way there is no core
file that I'd have to delete later.

> Btw, I just tried another thing now: if I attempt to open the file using 
> elinks from a gnome-terminal (TERM=xterm), no crash happens !

Thank you.  That was the critical hint.

With commit 80a5c6d466af4bed62d4d0f57f7a8e596b2166b3,
I get this backtrace for the write that corrupts memory:

#0  0x080ac48b in set_hline at src/document/html/renderer.c:503
#1  0x080aba89 in put_chars at src/document/html/renderer.c:1673
#2  0x080da96d in convert_string_elinks at src/intl/charsets.c:1363
#3  0x080ab814 in put_chars_conv at src/document/html/renderer.c:1396
#4  0x080a568f in put_chrs at src/document/html/parser.c:155
#5  0x080bbbd6 in parse_html at src/document/html/parser/parse.c:779
#6  0x080aeaf6 in format_html_part at src/document/html/renderer.c:2244
#7  0x080b13a7 in format_cell at src/document/html/tables.c:91
#8  0x080b15d1 in draw_table_cell at src/document/html/tables.c:883
#9  0x080b1801 in draw_table_cells at src/document/html/tables.c:932
#10 0x080b2bd8 in format_table at src/document/html/tables.c:1334
#11 0x080b6cd8 in html_table at src/document/html/parser/general.c:664
#12 0x080bc4ce in start_element at src/document/html/parser/parse.c:986
#13 0x080bc891 in process_element at src/document/html/parser/parse.c:1156
#14 0x080bbccd in parse_html at src/document/html/parser/parse.c:792
#15 0x080aeaf6 in format_html_part at src/document/html/renderer.c:2244
#16 0x080b13a7 in format_cell at src/document/html/tables.c:91
#17 0x080b15d1 in draw_table_cell at src/document/html/tables.c:883
#18 0x080b1801 in draw_table_cells at src/document/html/tables.c:932
#19 0x080b2bd8 in format_table at src/document/html/tables.c:1334
#20 0x080b6cd8 in html_table at src/document/html/parser/general.c:664
#21 0x080bc4ce in start_element at src/document/html/parser/parse.c:986
#22 0x080bc891 in process_element at src/document/html/parser/parse.c:1156
#23 0x080bbccd in parse_html at src/document/html/parser/parse.c:792
#24 0x080aeaf6 in format_html_part at src/document/html/renderer.c:2244
#25 0x080b13a7 in format_cell at src/document/html/tables.c:91
#26 0x080b15d1 in draw_table_cell at src/document/html/tables.c:883
#27 0x080b1801 in draw_table_cells at src/document/html/tables.c:932
#28 0x080b2bd8 in format_table at src/document/html/tables.c:1334
#29 0x080b6cd8 in html_table at src/document/html/parser/general.c:664
#30 0x080bc4ce in start_element at src/document/html/parser/parse.c:986
#31 0x080bc891 in process_element at src/document/html/parser/parse.c:1156
#32 0x080bbccd in parse_html at src/document/html/parser/parse.c:792
#33 0x080aeaf6 in format_html_part at src/document/html/renderer.c:2244
#34 0x080af054 in render_html_document at src/document/html/renderer.c:2350
#35 0x0809a23f in render_encoded_document at src/document/renderer.c:266
#36 0x0809a4b4 in render_document at src/document/renderer.c:346
#37 0x0809aa66 in render_document_frames at src/document/renderer.c:475
#38 0x08150d9a in draw_formatted at src/viewer/text/draw.c:351
#39 0x08131263 in display_timer at src/session/session.c:454
#40 0x081354ed in loading_callback at src/session/task.c:538
#41 0x080e796a in notify_connection_callbacks at src/network/connection.c:458
#42 0x080e7a66 in done_connection at src/network/connection.c:475
#43 0x080e887c in abort_connection at src/network/connection.c:769
#44 0x0810bf8b in file_protocol_handler at src/protocol/file/file.c:315
#45 0x080e87b3 in run_connection at src/network/connection.c:753
#46 0x080e8d2a in try_connection at src/network/connection.c:823
#47 0x080e8be0 in check_queue at src/network/connection.c:857
#48 0x080e1f12 in check_bottom_halves at src/main/select.c:115
#49 0x080e25e2 in select_loop at src/main/select.c:290
#50 0x080e1924 in main at src/main/main.c:358

Line 503 of src/document/html/renderer.c is:
POS(document->comb_x, document->comb_y).data = prev;

Interesting values:
document->comb_x = 113;
document->comb_y = 83;
part->box = {x = 17, y = 9, width = 102, height = 85};
part->document->data[part->box.y + document->comb_y].length = 119;

Witekfl, how do we fix this?  I already tried the following patch
(thinking that perhaps document->box had been changed but comb_x
and comb_y had not) but it didn't help.

diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c
index bbb4e4c..6735f9f 100644
--- a/src/document/html/renderer.c
+++ b/src/document/html/renderer.c
@@ -500,7 +500,8 @@ good_char:
                                                        unicode_val_T prev = 
get_combined(document->combi, document->combi_length + 1);
 
                                                        if (prev != UCS_NO_CHAR)
-                                                               
POS(document->comb_x, document->comb_y).data = prev;
+                                                               
part->document->data[document->comb_y]
+                                                                       
.chars[document->comb_x].data = prev;
                                                }
                                                document->combi_length = 0;
                                        }
@@ -526,8 +527,8 @@ good_char:
                                        schar->data = (unicode_val_T)data;
                                }
 #ifdef CONFIG_COMBINE
-                               document->comb_x = x;
-                               document->comb_y = y;
+                               document->comb_x = X(x);
+                               document->comb_y = Y(y);
 #endif
                                copy_screen_chars(&POS(x++, y), schar, 1);
                        } /* while chars < end */
> How do I use valgrind ?

Generally you can just run
  valgrind --log-file=/some/file elinks
and examine the log file afterwards.  If you want to examine the state
of ELinks as soon as an invalid pointer is used, you can instead do
  valgrind --db-attach=yes elinks
but then you may have to reset the terminal settings with e.g.
  stty sane < /dev/pts/6
From another terminal before you can answer valgrind's prompt.

Valgrind tends to report many errors in Guile and Python
libraries, so if you link ELinks with them, you should suppress
those errors so that you can focus on ELinks itself.  I set up
the following file for --suppressions=valgrind.suppressions:

{
   guile-heap-find-cond
   Memcheck:Cond
   fun:scm_i_find_heap_segment_containing_object
   fun:scm_mark_locations
   fun:scm_threads_mark_stacks
   fun:scm_mark_all
   fun:scm_i_gc
}

{
   guile-heap-mark-cond
   Memcheck:Cond
   fun:scm_gc_mark
}

{
   guile-heap-mark-value4
   Memcheck:Value4
   fun:scm_gc_mark
}

{
   guile-heap-markdep-cond
   Memcheck:Cond
   fun:scm_gc_mark_dependencies
}

{
   guile-heap-markdep-value4
   Memcheck:Value4
   fun:scm_gc_mark_dependencies
}

{
   guile-heap-markstr-value4
   Memcheck:Value4
   fun:scm_i_string_mark
}

{
   guile-heap-marksym-value4
   Memcheck:Value4
   fun:scm_i_symbol_mark
}

{
   guile-heap-markweakvec-cond
   Memcheck:Cond
   fun:scm_i_mark_weak_vectors_non_weaks
}

{
   guile-heap-rmweakvec-cond
   Memcheck:Cond
   fun:scm_i_remove_weaks_from_weak_vectors
}

{
   guile-heap-sweep-cond
   Memcheck:Cond
   fun:scm_i_sweep_card
   fun:scm_i_sweep_some_cards
   fun:scm_i_sweep_some_segments
}

{
   guile-heap-markcdr-value4
   Memcheck:Value4
   fun:scm_markcdr
   fun:scm_gc_mark
}

{
   python-heap-free-addr4
   Memcheck:Addr4
   fun:PyObject_Free
}

{
   python-heap-free-value4
   Memcheck:Value4
   fun:PyObject_Free
}

{
   python-heap-free-cond
   Memcheck:Cond
   fun:PyObject_Free
}
I haven't yet read the documentation on suppressions files, so
there probably are better ways of writing these suppressions.

Attachment: pgpwsrKNy6QM3.pgp
Description: PGP signature

_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev

Reply via email to