History

lib/bcheck: Fix code typo in __bound_delete_region()

We were calling get_page() with t2 index which is not correct, since get_page() operate on t1 indices. The bug is here from day-1, from 60f781c4 (first version of bounds checker) and show as a crash in __bound_delete_region() at program exit: $ ./tcc -B. -DTCC_TARGET_I386 -DCONFIG_MULTIARCHDIR=\"i386-linux-gnu\" -b -run -DONE_SOURCE \ ./tcc.c -B. -DTCC_TARGET_I386 -DCONFIG_MULTIARCHDIR=\"i386-linux-gnu\" -run -DONE_SOURCE \ ./tcc.c -B. -run tests/tcctest.c (lot's of correct output from tcctest) Runtime error: dereferencing invalid pointer at 0xa7c21cc4 __bound_delete_region() by (nil) ??? Segmentation fault The fix is simple - last page should be get through t1_end, like it is done in __bound_new_region(). After this patch, tcc is being able to compile itself with -b, then compile itself again and run tcctest with correct output. Tests follow.

Kirill Smelkov committed 13 years ago

Commit dbeb4fa1 parent efd9d921 file · +1 −1Browse files

Unified · Split

lib/bcheck.c+1−1
@@ -613,7 +613,7 @@ int __bound_delete_region(void *p) · 612 unmodified lines
613 }613 }
614 }614 }
615 /* last page */615 /* last page */
616 page = get_page(t2_end);616 page = get_page(t1_end);
617 e2 = (BoundEntry *)((char *)page + t2_end);617 e2 = (BoundEntry *)((char *)page + t2_end);
618 for(e=page;e<e2;e++) {618 for(e=page;e<e2;e++) {
619 e->start = 0;619 e->start = 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t