Commit Graph

617 Commits

Author SHA1 Message Date
Michael Lotz ec0190adb0 malloc_debug: Implement allocation dump on exit in guarded heap.
When enabled (using heap_debug_dump_allocations_on_exit(true) or
MALLOC_DEBUG=e) this causes a dump of all remaining allocations when
libroot_debug is unloaded. It uses terminate_after to be called as
late as possible.

When combined with alloc stack traces this makes for a nice if a bit
crude leak checker. Note that a lot of allocations usually remain
even at that stage due to statically, lazyly and globally allocated
stuff from the various system libraries where it isn't necessarily
worth the overhead to free them when the program terminates anyway.
2015-04-10 17:04:28 +02:00
Michael Lotz 158e20e60e malloc_debug: Implement alloc/free stack traces in guarded heap.
When configured to do so (using heap_debug_set_stack_trace_depth(depth)
or MALLOC_DEBUG=s<depth>) the guarded heap now captures stack traces on
alloc and free.

A crash due to hitting a guard page or an already freed page now dumps
these stack traces. In the case of use-after-free one can therefore see
both where the allocation was done and where it was freed.

Note that there is a hardcoded maximum stack trace depth of 50 and that
the alloc stack trace takes away space from the free stack trace which
uses up the rest of that maximum.
2015-04-10 16:28:42 +02:00
Michael Lotz 121655e9ee malloc_debug: Add default alignment option.
This allows for something similar as was implemented in 217f090 but
makes it optional and configurable.

The MALLOC_DEBUG environment variable now can take "a<size>" to set
the default alignment to the specified size. Note that not all
alignments may be supported depending on the heap implementation.
2015-04-04 22:55:57 +02:00
Michael Lotz a05bfeb4a9 Whitespace cleanup only. 2015-04-04 22:55:56 +02:00
Jérôme Duval 4a9c56f6c7 x86_64: fenv.c needs __weak_reference()
* the weak symbol feenableexcept wasn't available.
2015-03-27 20:16:57 +01:00
Timothy Gu d1dc9cf655 stdint.h: use correct type for INT64_MAX (#11647)
int64_t is signed. Although it does not make a difference by itself, because
INT64_MAX is still a valid number for uint64_t (UL), the later INT64_MIN
declaration depends on INT64_MAX, and therefore got implicitly casted to
unsigned type.

This fixes the following program on a x86_64 system:

	#include <stdint.h>

	int main() {
		int64_t test = 5;
		if (test < INT64_MIN)
			return 1;
		return 0;
	}

This is a regression since commit 1d13a609 ("stdint.h: define [U]INT64[MAX|MIN]
with [U]L on x86_64").

Signed-off-by: Jerome Duval <jerome.duval@gmail.com>
2014-12-20 10:06:21 +01:00
Puck Meerburg a5f30beaad Fix #7008: Add a64l and l64a from glibc, and add some missing definitions in wchar.h and stdlib.h
Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2014-12-14 18:06:09 +01:00
Jérôme Duval 1d13a60901 stdint.h: define [U]INT64[MAX|MIN] with [U]L on x86_64
instead of [U]LL
2014-12-14 15:55:14 +01:00
François Revol 12533060d0 stdio.h: add missing typedefs
I should sleep more and build more :D
2014-11-19 15:45:17 +01:00
François Revol e1f303c5ec Add fopencookie() to stdio.h
We already export it in libroot, and libassuan seems to require it.
2014-11-19 15:13:45 +01:00
François Revol 1436fe7448 Add TIOCM_CAR as a synonym for TIOCM_CD
Gnokii uses it.
2014-11-09 02:28:06 +01:00
Oliver Tappe b9c8e3de1b string.h: include strings.h for compatibility.
* Partly reverting hrev47655, as the moved declarations are expected
  by many ports to be accessable via string.h. 
  Following standards is a good thing in general, but not if it causes 
  more problems than it helps ...
2014-10-30 00:20:13 +01:00
Adrien Destugues 4ad7d95bac Revert "Add sys/ucontext.h"
This reverts commit 6ddf93bfbe.

As pointed out by Ingo, those were moved to sugnal.h in the latest issue
(issue 7) of the POSIX spec. Sorry!
2014-08-09 20:18:05 +02:00
Adrien Destugues 6ddf93bfbe Add sys/ucontext.h
* Move ucontext_t and mcontext_t there as that's where POSIX says they
should be.
2014-08-09 18:37:43 +02:00
Jérôme Duval 3aeed6607c include strings.h where appriopriate...
instead or additionally to string.h, in preparation for functions move.
* moves str[n]casecmp() functions and others to strings.h.
* strings.h doesn't include string.h anymore.
* this solves #10949
2014-08-08 22:40:37 +02:00
Jérôme Duval 4dc5ce8fd8 mknod[at](): moves from unistd.h to sys/stat.h
* this solves #10883.
2014-08-04 19:03:08 +02:00
François Revol 0be89c15ee tty: Add bitmask ioctls TIOCMBIS and TIOCMBIC
Equivalent to TIOCMSET + bitmask + TIOCMGET but with a single call.

Gnokii uses that.
2014-07-23 21:36:07 +02:00
Jérôme Duval 74e1a530f8 Revert unrelated part of 17aa359b5d. 2014-07-11 22:23:21 +02:00
Akshay Jaggi 17aa359b5d XHCI USB: Fixes.
* Add support for hubs in AllocateDevice().
* Prevent page fault in FinishTransfers().
* Set fCapabilityLength
* Correct in BIOS ownership code
* Fix context errors in _InsertEndpointForPipe().
* Update constants according to latest Specification (v1.1)
* Fix SMI code (reference
http://lkml.iu.edu/hypermail/linux/kernel/1204.2/02460.html).
* Fix Memory/Device-Slot leaks.
* Fix area allocation for TRBs.
* Fix for Intel Lynx Point and Panther Point chipsets. Also move init
of xhci before ehci, to switch USB 2.0 ports before the ehci module
discovers them.

Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2014-07-11 22:14:05 +02:00
Jérôme Duval 2f32fd1dde wchar.h & string.h: use _GNU_SOURCE instead of __USE_GNU. 2014-06-07 11:22:38 +02:00
Jérôme Duval a3b79608f9 search.h: fix typo.
* Thanks diger for noticing.
2014-06-07 10:54:15 +02:00
Jessica Hamilton fad4fc59f9 Revert "ByteOrder.h: remove use of __builtin_bswap16."
This reverts commit 040dc2eebc.
2014-05-30 20:39:43 +12:00
Jessica Hamilton 040dc2eebc ByteOrder.h: remove use of __builtin_bswap16.
* Fixes the build for host compilers older than gcc-4.8
2014-05-30 08:45:57 +12:00
Adrien Destugues 8d250951a3 Fix ptrdiff_t limits introduced in r24654 (!)
* The ptrdiff_t limits are PTRDIFF_MIN and PTRDIFF_MAX, not PTDIFF_*.
* I could not find any non-Haiku reference to PTDIFF_*, so I guess
that's a mistake.
2014-04-29 10:26:23 +02:00
Jérôme Duval 53dd259b4d added tar.h posix header.
* based on http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/tar.h.html
2014-04-26 11:09:24 +02:00
Jonathan Schleifer 92bd26ce8e stdio.h: Add missing *_unlocked declarations
Configure scripts would find the symbols and thus use them and assume
our headers declare them.

This fixes building gcc_bootstrap.
2014-03-09 23:08:51 +01:00
Alexander von Gluck IV 122d1cddc9 Haiku: Fix posix INT64_C macros on x86_64
* Was causing LLVM to fail to build on x86_64
* Make XINT64 adjust based on architecture like
  config/types.h to ensure these macros match
  uint64 and int64 at all times.
* Resolves #10566
2014-02-21 01:38:54 -06:00
Pawel Dziepak d0f2d8282f Merge branch 'scheduler'
Conflicts:
	build/jam/packages/Haiku
	headers/os/kernel/OS.h
	headers/os/opengl/GLRenderer.h
	headers/private/shared/cpu_type.h
	src/add-ons/kernel/drivers/power/acpi_battery/acpi_battery.h
	src/bin/sysinfo.cpp
	src/bin/top.c
	src/system/kernel/arch/x86/arch_system_info.cpp
	src/system/kernel/port.cpp
2014-01-17 04:06:15 +01:00
Pawel Dziepak 79c9b824e4 libroot: sync() should not return any value 2014-01-16 20:18:22 +01:00
Adrien Destugues 9cdbb95476 Remove comment. 2013-12-21 21:58:28 +01:00
Adrien Destugues c516bac9f4 Revert part of hrev24647
The baudrate constant for MIDI speed was after all the others in BeOS,
and we have to keep them with the same values for things to work.
Moreover, the constants in SerialPort.h were not changed, so everything
was out of sync and all apps using BSerialPort ended up using the wrong
speed.

Add a comment in termios.h to make sure this doesn't happen again.
2013-12-21 20:25:24 +01:00
Pawel Dziepak fd96cf08a7 libroot: Remove _SC_NPROCESSORS_MAX and _SC_CPUID_MAX
_SC_NPROCESSORS_MAX and _SC_CPUID_MAX appear to be supported only by
Solaris. There isn't much point in exposing such values to the userland
anyway.
2013-12-06 21:54:07 +01:00
Ithamar R. Adema d22fdcae7d ARM: remove #warning from public header file
This causes configure of gcc/binutils to fail its test for sys/time.h, which
in turn causes compilation of gcc/binutils to fail.

Found trying to do a @bootstrap-raw build for ARM.
2013-10-28 22:04:00 +01:00
Sam Toyer b236c48e09 Add missing definitions to math.h
Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
2013-10-01 19:48:51 +02:00
Adrien Destugues 7650931572 Rename parameters to avoid compile error
* warning: declaration of `signal' shadows global declaration
2013-10-01 17:17:28 +02:00
Ingo Weinhold 81291304ad Merge remote-tracking branch 'haiku/master' into package-management
Conflicts:
	build/jam/BuildSetup
	build/jam/HaikuImage
	build/jam/board/sam460ex/BoardSetup
	build/jam/board/verdex/BoardSetup
	data/catalogs/apps/icon-o-matic/fr.catkeys
	src/add-ons/kernel/drivers/audio/hda/hda_codec.cpp
	src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp
	src/apps/debugger/files/FileManager.cpp
	src/apps/debugger/files/FileManager.h
	src/apps/debugger/user_interface/gui/inspector_window/MemoryView.cpp
	src/apps/haiku-depot/MainWindow.cpp
	src/apps/haiku-depot/MainWindow.h
	src/apps/haiku-depot/Model.cpp
	src/apps/haiku-depot/PackageInfo.h
	src/apps/haiku-depot/PackageInfoListener.h
	src/apps/haiku-depot/PackageInfoView.cpp
	src/apps/haiku-depot/PackageInfoView.h
	src/apps/haiku-depot/PackageListView.cpp
	src/apps/haiku-depot/PackageListView.h
	src/system/kernel/arch/arm/arch_timer.cpp
	src/system/libroot/os/arch/arm/atomic.S
	src/tools/translation/bitsinfo/Jamfile
	src/tools/translation/bmpinfo/Jamfile
	src/tools/translation/tgainfo/Jamfile
2013-09-27 01:55:45 +02:00
Pawel Dziepak afaa6ed4b3 x86[_64]: Randomize initial stack pointer on alternative signal stacks
If the alternate signal stack is used randomize the initial stack
pointer in the same way it is randomized on "normal" thread stacks.
Also, update MINSIGSTKSZ value so that regardless of where the new
stack pointer points to there is at least 4k of stack left.
2013-09-21 21:52:13 +02:00
Pawel Dziepak 4efb0a6d36 posix: Update PTHREAD_STACK_MIN to match MIN_USER_STACK_SIZE
Thanks for pointing this out Pete!
2013-09-17 14:42:04 +02:00
Jérôme Duval 5a2c5827e4 add a constant for 10G base T ethernet. 2013-09-17 14:40:21 +02:00
Pawel Dziepak aca204991f posix: Update PTHREAD_STACK_MIN to match MIN_USER_STACK_SIZE
Thanks for pointing this out Pete!
2013-09-16 23:23:29 +02:00
Jérôme Duval b31f2d53e0 add a constant for 10G base T ethernet. 2013-09-14 18:11:43 +02:00
Ingo Weinhold c625c5fd36 <langinfo.h>/<select.h>: don't use C++ comments 2013-06-12 14:55:16 +02:00
Ingo Weinhold a1832a0e83 <resolv.h>: Make self-contained 2013-06-11 15:23:18 +02:00
Alexander von Gluck IV 88e9c0961a libnetwork: Check for ipv4 flag in resolv.conf
* Add option for forced IPv4 resolution.
* Helps with #8293
* Very slightly modified patch by donn
2013-04-14 17:03:32 -05:00
Landon Fuller 524bb6d3ec Restore FTS_WHITEOUT, guard it with __HAIKU__.
As per Jérôme Duval's code review in issue #9337.
2013-01-11 00:26:48 +01:00
Landon Fuller 4b5a13ab81 Add Haiku support.
This replaces the use of a few BSD-specific functions, as well
as the direct references to _open/_close et-al.

BFS doesn't support the FTS_NOSTAT directory link count optimization,
and no statfs() function is available, so we simply turn that off.
2013-01-11 00:26:48 +01:00
Landon Fuller 7de6d45ca2 Drop in unmodified fts/ftw implementations from FreeBSD HEAD (r245067). 2013-01-11 00:26:47 +01:00
Jérôme Duval ef769e5e87 add declaration of sa_family_t in sys/socket.h
* added missing declaration of sa_family_t in sys/socket.h, this fixes #8731
  thanks to Anarchos for the patch.
* fixed the build of the command ftp
2012-12-28 22:28:13 +01:00
Hamish Morrison d1f280c805 Add support for pthread_attr_get/setguardsize()
* Added the aforementioned functions.
* create_area_etc() now takes a guard size parameter.
* The thread_info::stack_base/end range now refers to the usable range
  only.
2012-12-28 18:02:58 +00:00
Jérôme Duval 00e7904406 include string.h for FD_ZERO in sys/select.h
* sys/select.h was not self contained before, this fixes #9327
* index is defined as a function in string.h, fixed resulting name
  collision in glut_shapes.c
2012-12-28 18:30:03 +01:00