Skip to content

Commit 3cac76b

Browse files
committed
Auto merge of #24344 - gfxmonk:update-libbacktrace, r=pnkfelix
On linux, certain crashes can cause rust's backtrace generation code to consume huge amounts of memory (multiple gigabytes) when trying to generate a backtrace (e.g. servo/servo#5340). I tracked this down to a bug in libbacktrace's allocation strategy when processing large binaries, and thankfully it's already been fixed upstream. The change which fixes this specific issue is r210256, and is discussed here: https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00547.html I assume we'd prefer to update libbacktrace wholesale, rather than cherry-picking individual patches, so this PR updates libbacktrace to the latest code from svn://gcc.gnu.org/svn/gcc/trunk/libbacktrace (r220112). I've copied the upstream code and reapplied the parts of the following commits which touch src/libbacktrace: - cd8f317 - fcb30a0 I have not reapplied f576579 or d51047d, as those are both cosmetic cleanups applied to the entire codebase. For this directory, it seems worthwhile diverging as little as possible from upstream, to reduce the effort of future updates. But I can add them as well if preferred.
2 parents 5245475 + 10073c2 commit 3cac76b

27 files changed

+546
-182
lines changed

src/libbacktrace/ChangeLog

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,56 @@
1+
2015-01-24 Matthias Klose <[email protected]>
2+
3+
* configure.ac: Move AM_ENABLE_MULTILIB before AC_PROG_CC.
4+
* configure: Regenerate.
5+
6+
2015-01-05 Jakub Jelinek <[email protected]>
7+
8+
Update copyright years.
9+
10+
2014-11-21 H.J. Lu <[email protected]>
11+
12+
PR bootstrap/63784
13+
* configure: Regenerated.
14+
15+
2014-11-11 David Malcolm <[email protected]>
16+
17+
* ChangeLog.jit: New.
18+
19+
2014-11-11 Francois-Xavier Coudert <[email protected]>
20+
21+
PR target/63610
22+
* configure: Regenerate.
23+
24+
2014-10-23 Ian Lance Taylor <[email protected]>
25+
26+
* internal.h (backtrace_atomic_load_pointer) [no atomic or sync]:
27+
Fix to return void *.
28+
29+
2014-05-08 Ian Lance Taylor <[email protected]>
30+
31+
* mmap.c (backtrace_free): If freeing a large aligned block of
32+
memory, call munmap rather than holding onto it.
33+
(backtrace_vector_grow): When growing a vector, double the number
34+
of pages requested. When releasing the old version of a grown
35+
vector, pass the correct size to backtrace_free.
36+
37+
2014-03-07 Ian Lance Taylor <[email protected]>
38+
39+
* sort.c (backtrace_qsort): Use middle element as pivot.
40+
41+
2014-03-06 Ian Lance Taylor <[email protected]>
42+
43+
* sort.c: New file.
44+
* stest.c: New file.
45+
* internal.h (backtrace_qsort): Declare.
46+
* dwarf.c (read_abbrevs): Call backtrace_qsort instead of qsort.
47+
(read_line_info, read_function_entry): Likewise.
48+
(read_function_info, build_dwarf_data): Likewise.
49+
* elf.c (elf_initialize_syminfo): Likewise.
50+
* Makefile.am (libbacktrace_la_SOURCES): Add sort.c.
51+
(stest_SOURCES, stest_LDADD): Define.
52+
(check_PROGRAMS): Add stest.
53+
154
2014-02-07 Misty De Meo <[email protected]>
255

356
PR target/58710

src/libbacktrace/ChangeLog.jit

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2014-09-24 David Malcolm <[email protected]>
2+
3+
* ChangeLog.jit: Add copyright footer.
4+
5+
2013-10-03 David Malcolm <[email protected]>
6+
7+
* configure.ac: Add --enable-host-shared.
8+
* configure: Regenerate.
9+
10+
Copyright (C) 2013-2014 Free Software Foundation, Inc.
11+
12+
Copying and distribution of this file, with or without modification,
13+
are permitted in any medium without royalty provided the copyright
14+
notice and this notice are preserved.

src/libbacktrace/Makefile.am

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Makefile.am -- Backtrace Makefile.
2-
# Copyright (C) 2012-2014 Free Software Foundation, Inc.
2+
# Copyright (C) 2012-2015 Free Software Foundation, Inc.
33

44
# Redistribution and use in source and binary forms, with or without
55
# modification, are permitted provided that the following conditions are
66
# met:
77

88
# (1) Redistributions of source code must retain the above copyright
9-
# notice, this list of conditions and the following disclaimer.
9+
# notice, this list of conditions and the following disclaimer.
1010

1111
# (2) Redistributions in binary form must reproduce the above copyright
1212
# notice, this list of conditions and the following disclaimer in
1313
# the documentation and/or other materials provided with the
14-
# distribution.
14+
# distribution.
1515

1616
# (3) The name of the author may not be used to
1717
# endorse or promote products derived from this software without
@@ -46,6 +46,7 @@ libbacktrace_la_SOURCES = \
4646
internal.h \
4747
posix.c \
4848
print.c \
49+
sort.c \
4950
state.c
5051

5152
BACKTRACE_FILES = \
@@ -93,6 +94,11 @@ btest_LDADD = libbacktrace.la
9394

9495
check_PROGRAMS += btest
9596

97+
stest_SOURCES = stest.c
98+
stest_LDADD = libbacktrace.la
99+
100+
check_PROGRAMS += stest
101+
96102
endif NATIVE
97103

98104
# We can't use automake's automatic dependency tracking, because it

src/libbacktrace/Makefile.in

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
# met:
2424

2525
# (1) Redistributions of source code must retain the above copyright
26-
# notice, this list of conditions and the following disclaimer.
26+
# notice, this list of conditions and the following disclaimer.
2727

2828
# (2) Redistributions in binary form must reproduce the above copyright
2929
# notice, this list of conditions and the following disclaimer in
3030
# the documentation and/or other materials provided with the
31-
# distribution.
31+
# distribution.
3232

3333
# (3) The name of the author may not be used to
3434
# endorse or promote products derived from this software without
@@ -67,7 +67,7 @@ build_triplet = @build@
6767
host_triplet = @host@
6868
target_triplet = @target@
6969
check_PROGRAMS = $(am__EXEEXT_1)
70-
@NATIVE_TRUE@am__append_1 = btest
70+
@NATIVE_TRUE@am__append_1 = btest stest
7171
subdir = .
7272
DIST_COMMON = README ChangeLog $(srcdir)/Makefile.in \
7373
$(srcdir)/Makefile.am $(top_srcdir)/configure \
@@ -94,15 +94,18 @@ CONFIG_CLEAN_VPATH_FILES =
9494
LTLIBRARIES = $(noinst_LTLIBRARIES)
9595
am__DEPENDENCIES_1 =
9696
am_libbacktrace_la_OBJECTS = atomic.lo dwarf.lo fileline.lo posix.lo \
97-
print.lo state.lo
97+
print.lo sort.lo state.lo
9898
libbacktrace_la_OBJECTS = $(am_libbacktrace_la_OBJECTS)
99-
@NATIVE_TRUE@am__EXEEXT_1 = btest$(EXEEXT)
99+
@NATIVE_TRUE@am__EXEEXT_1 = btest$(EXEEXT) stest$(EXEEXT)
100100
@NATIVE_TRUE@am_btest_OBJECTS = btest-btest.$(OBJEXT)
101101
btest_OBJECTS = $(am_btest_OBJECTS)
102102
@NATIVE_TRUE@btest_DEPENDENCIES = libbacktrace.la
103103
btest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
104104
--mode=link $(CCLD) $(btest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
105105
$(LDFLAGS) -o $@
106+
@NATIVE_TRUE@am_stest_OBJECTS = stest.$(OBJEXT)
107+
stest_OBJECTS = $(am_stest_OBJECTS)
108+
@NATIVE_TRUE@stest_DEPENDENCIES = libbacktrace.la
106109
DEFAULT_INCLUDES = -I.@am__isrc@
107110
depcomp =
108111
am__depfiles_maybe =
@@ -116,11 +119,11 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
116119
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
117120
$(LDFLAGS) -o $@
118121
SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \
119-
$(btest_SOURCES)
120-
MULTISRCTOP =
121-
MULTIBUILDTOP =
122-
MULTIDIRS =
123-
MULTISUBDIR =
122+
$(btest_SOURCES) $(stest_SOURCES)
123+
MULTISRCTOP =
124+
MULTIBUILDTOP =
125+
MULTIDIRS =
126+
MULTISUBDIR =
124127
MULTIDO = true
125128
MULTICLEAN = true
126129
ETAGS = etags
@@ -264,6 +267,7 @@ libbacktrace_la_SOURCES = \
264267
internal.h \
265268
posix.c \
266269
print.c \
270+
sort.c \
267271
state.c
268272

269273
BACKTRACE_FILES = \
@@ -300,6 +304,8 @@ TESTS = $(check_PROGRAMS)
300304
@NATIVE_TRUE@btest_SOURCES = btest.c
301305
@NATIVE_TRUE@btest_CFLAGS = $(AM_CFLAGS) -g -O
302306
@NATIVE_TRUE@btest_LDADD = libbacktrace.la
307+
@NATIVE_TRUE@stest_SOURCES = stest.c
308+
@NATIVE_TRUE@stest_LDADD = libbacktrace.la
303309

304310
# We can't use automake's automatic dependency tracking, because it
305311
# breaks when using bootstrap-lean. Automatic dependency tracking
@@ -362,7 +368,7 @@ config.h: stamp-h1
362368
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
363369
@rm -f stamp-h1
364370
cd $(top_builddir) && $(SHELL) ./config.status config.h
365-
$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
371+
$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
366372
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
367373
rm -f stamp-h1
368374
touch $@
@@ -380,7 +386,7 @@ clean-noinstLTLIBRARIES:
380386
echo "rm -f \"$${dir}/so_locations\""; \
381387
rm -f "$${dir}/so_locations"; \
382388
done
383-
libbacktrace.la: $(libbacktrace_la_OBJECTS) $(libbacktrace_la_DEPENDENCIES)
389+
libbacktrace.la: $(libbacktrace_la_OBJECTS) $(libbacktrace_la_DEPENDENCIES)
384390
$(LINK) $(libbacktrace_la_OBJECTS) $(libbacktrace_la_LIBADD) $(LIBS)
385391

386392
clean-checkPROGRAMS:
@@ -391,9 +397,12 @@ clean-checkPROGRAMS:
391397
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
392398
echo " rm -f" $$list; \
393399
rm -f $$list
394-
btest$(EXEEXT): $(btest_OBJECTS) $(btest_DEPENDENCIES)
400+
btest$(EXEEXT): $(btest_OBJECTS) $(btest_DEPENDENCIES)
395401
@rm -f btest$(EXEEXT)
396402
$(btest_LINK) $(btest_OBJECTS) $(btest_LDADD) $(LIBS)
403+
stest$(EXEEXT): $(stest_OBJECTS) $(stest_DEPENDENCIES)
404+
@rm -f stest$(EXEEXT)
405+
$(LINK) $(stest_OBJECTS) $(stest_LDADD) $(LIBS)
397406

398407
mostlyclean-compile:
399408
-rm -f *.$(OBJEXT)

src/libbacktrace/alloc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/* alloc.c -- Memory allocation without mmap.
2-
Copyright (C) 2012-2014 Free Software Foundation, Inc.
2+
Copyright (C) 2012-2015 Free Software Foundation, Inc.
33
Written by Ian Lance Taylor, Google.
44
55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are
77
met:
88
99
(1) Redistributions of source code must retain the above copyright
10-
notice, this list of conditions and the following disclaimer.
10+
notice, this list of conditions and the following disclaimer.
1111
1212
(2) Redistributions in binary form must reproduce the above copyright
1313
notice, this list of conditions and the following disclaimer in
1414
the documentation and/or other materials provided with the
15-
distribution.
16-
15+
distribution.
16+
1717
(3) The name of the author may not be used to
1818
endorse or promote products derived from this software without
1919
specific prior written permission.

src/libbacktrace/atomic.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/* atomic.c -- Support for atomic functions if not present.
2-
Copyright (C) 2013-2014 Free Software Foundation, Inc.
2+
Copyright (C) 2013-2015 Free Software Foundation, Inc.
33
Written by Ian Lance Taylor, Google.
44
55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are
77
met:
88
99
(1) Redistributions of source code must retain the above copyright
10-
notice, this list of conditions and the following disclaimer.
10+
notice, this list of conditions and the following disclaimer.
1111
1212
(2) Redistributions in binary form must reproduce the above copyright
1313
notice, this list of conditions and the following disclaimer in
1414
the documentation and/or other materials provided with the
15-
distribution.
16-
15+
distribution.
16+
1717
(3) The name of the author may not be used to
1818
endorse or promote products derived from this software without
1919
specific prior written permission.

src/libbacktrace/backtrace-supported.h.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/* backtrace-supported.h.in -- Whether stack backtrace is supported.
2-
Copyright (C) 2012-2014 Free Software Foundation, Inc.
2+
Copyright (C) 2012-2015 Free Software Foundation, Inc.
33
Written by Ian Lance Taylor, Google.
44
55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are
77
met:
88
99
(1) Redistributions of source code must retain the above copyright
10-
notice, this list of conditions and the following disclaimer.
10+
notice, this list of conditions and the following disclaimer.
1111
1212
(2) Redistributions in binary form must reproduce the above copyright
1313
notice, this list of conditions and the following disclaimer in
1414
the documentation and/or other materials provided with the
15-
distribution.
16-
15+
distribution.
16+
1717
(3) The name of the author may not be used to
1818
endorse or promote products derived from this software without
1919
specific prior written permission.

src/libbacktrace/backtrace.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/* backtrace.c -- Entry point for stack backtrace library.
2-
Copyright (C) 2012-2014 Free Software Foundation, Inc.
2+
Copyright (C) 2012-2015 Free Software Foundation, Inc.
33
Written by Ian Lance Taylor, Google.
44
55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are
77
met:
88
99
(1) Redistributions of source code must retain the above copyright
10-
notice, this list of conditions and the following disclaimer.
10+
notice, this list of conditions and the following disclaimer.
1111
1212
(2) Redistributions in binary form must reproduce the above copyright
1313
notice, this list of conditions and the following disclaimer in
1414
the documentation and/or other materials provided with the
15-
distribution.
16-
15+
distribution.
16+
1717
(3) The name of the author may not be used to
1818
endorse or promote products derived from this software without
1919
specific prior written permission.

src/libbacktrace/backtrace.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/* backtrace.h -- Public header file for stack backtrace library.
2-
Copyright (C) 2012-2014 Free Software Foundation, Inc.
2+
Copyright (C) 2012-2015 Free Software Foundation, Inc.
33
Written by Ian Lance Taylor, Google.
44
55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are
77
met:
88
99
(1) Redistributions of source code must retain the above copyright
10-
notice, this list of conditions and the following disclaimer.
10+
notice, this list of conditions and the following disclaimer.
1111
1212
(2) Redistributions in binary form must reproduce the above copyright
1313
notice, this list of conditions and the following disclaimer in
1414
the documentation and/or other materials provided with the
15-
distribution.
16-
15+
distribution.
16+
1717
(3) The name of the author may not be used to
1818
endorse or promote products derived from this software without
1919
specific prior written permission.

src/libbacktrace/btest.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/* btest.c -- Test for libbacktrace library
2-
Copyright (C) 2012-2014 Free Software Foundation, Inc.
2+
Copyright (C) 2012-2015 Free Software Foundation, Inc.
33
Written by Ian Lance Taylor, Google.
44
55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are
77
met:
88
99
(1) Redistributions of source code must retain the above copyright
10-
notice, this list of conditions and the following disclaimer.
10+
notice, this list of conditions and the following disclaimer.
1111
1212
(2) Redistributions in binary form must reproduce the above copyright
1313
notice, this list of conditions and the following disclaimer in
1414
the documentation and/or other materials provided with the
15-
distribution.
16-
15+
distribution.
16+
1717
(3) The name of the author may not be used to
1818
endorse or promote products derived from this software without
1919
specific prior written permission.
@@ -460,7 +460,7 @@ f23 (int f1line, int f2line)
460460
(unsigned int) bdata.index, j + 1);
461461
bdata.failed = 1;
462462
}
463-
}
463+
}
464464

465465
check ("test3", 0, all, f3line, "f23", &bdata.failed);
466466
check ("test3", 1, all, f2line, "f22", &bdata.failed);

0 commit comments

Comments
 (0)