Commit Graph

60487 Commits

Author SHA1 Message Date
Adrien Destugues
ec2b89264c oce_if: fix oout of bounds access
Change-Id: Id052d9e7714c0251e39384671da9a0f76f6c13c4
Reviewed-on: https://review.haiku-os.org/c/1682
Reviewed-by: Rene Gollent <rene@gollent.com>
2019-08-06 03:18:36 +00:00
Augustin Cavalier
af0be8dbc5 kernel/condition_variable: Clean up comments and reduce needless unlocks.
This "race prevention" code does not seem to be really hit at all
in practice, at least from testing, so no need to do a full
unlock/lock universally for it.

I'm still not sure why the previous fixes here removed 80% of
the performance benefits of the original change; I need to
investigate that more.
2019-08-05 22:58:28 -04:00
Augustin Cavalier
2c588b031f kernel: Properly separate and handle THREAD_BLOCK_TYPE_USER.
Consider this scenario:
 * A userland thread puts its ID into some structure so that it
   can be woken up later, sets its wait_status to initiate the
   begin of the wait, and then calls _user_block_thread.
 * A second thread finishes whatever task the first thread
   intended to wait for, reads the ID almost immediately
   after it was written, and calls _user_unblock_thread.
 * _user_unblock_thread was called so soon that the first
   thread is not yet blocked on the _user_block_thread block,
   but is instead blocked on e.g. the thread's main mutex.
 * The first thread's thread_block() call returns B_OK.
   As in this example it was inside mutex_lock, it thinks
   that it now owns the mutex.
 * But it doesn't own the mutex, and so (until yesterday)
   all sorts of mayhem and then a random crash occurs, or
   (after yesterday) an assert-failure is tripped that
   the thread does not own the mutex it expected to.

The above scenario is not a hypothetical, but is in fact the
exact scenario behind the strange panics in #15211.

The solution is to only have _user_unblock_thread actually
unblock threads that were blocked by _user_block_thread,
so I've introduced a new BLOCK_TYPE to differentiate these.
While I'm at it, remove the BLOCK_TYPE_USER_BASE, which was
never used (and now never will be.) If we want to differentiate
different consumers of _user_block_thread for debugging
purposes, we should use the currently-unused "object"
argument to thread_block, instead of cluttering the
relatively-clean block type debugging code with special
types.

One final note: The race condition which was the case of
this bug does not, in fact, imply a deadlock on the part
of the rw_lock here. The wait_status is protected by the
thread's mutex, which is acquired by both _user_block_thread
and _user_unblock_thread, and so if _user_unblock_thread
succeeds faster than _user_block_thread can initiate
the block, it will just see that wait_status is already
<= 0 and return immediately.

Fixes #15211.
2019-08-05 22:31:02 -04:00
Pascal Abresch
64a4b621b8 added media and acpi keys to ps/2 driver
Change-Id: I92999325785dd81d2425cc06c70e9bedc26379ec
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1675
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-08-05 21:50:34 +00:00
Alexander von Gluck IV
6c331fc7e1 kit/package: Error on short file read
* It's safe to assume that if the file is shorter than
  the provided header, things will go poorly.
* Avoids a random vauge ReadBuffer error.
* This doesn't fix #15230, but makes the issue clearer.

Change-Id: I3471e6de384a0c9be94049ad891c01be980f7846
Reviewed-on: https://review.haiku-os.org/c/1679
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-08-05 15:07:24 +00:00
Andrew Lindesay
02e836dc3c HaikuDepot: Barber Pole Idle Appearance
This change renders a striped background in the
'barber pole' in HaikuDepot application when it is
idle.  This makes the 'barber pole' easier to use
in situations where the space that the UI control
takes up should not be blank.  The logic for the
striped background is from the 'drivesetup'
application.

Change-Id: I87791c70b4d1a21d91e661433d6c940ca69ece87
Reviewed-on: https://review.haiku-os.org/c/1674
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-08-05 07:39:39 +00:00
Augustin Cavalier
719cfad7fd kernel/user_debugger: Don't try to cast an integer to a pointer.
Should fix the x86_64 build.
2019-08-04 20:12:53 -04:00
Augustin Cavalier
9dc67a1d96 kernel/condition_variable: Rework remove-from-condition logic again.
This avoids a few potential race conditions mmlr pointed out on
the mailing list. See inline comments.

Change-Id: I605523c1d2683c749751599c417a68a20c70edea
2019-08-04 20:10:15 -04:00
Augustin Cavalier
8dae411c1e kernel/locks: Tweak mutex_unlock KDEBUG semantics slightly.
Previously, both the "old" owner and the "new" lock owner set
the lock holder to the "new" lock holder. Now the old owner does
it before calling unblock(), and we check in the lock() functions
that we are indeed the new owner of the lock.

This may affect what the panic is for #15211 and its duplicates:
I have a suspicion that these threads are getting unblocked
when they have no business being unblocked, and this should
catch that condition.
2019-08-04 19:08:03 -04:00
Augustin Cavalier
24f7b647cd kernel/user_debugger: Initialize the condition variables.
Should (actually) fix #15223 and #15226. After things settle
down a bit, I'll refactor our ConditionVariable constructors
to detect this at compile time instead of creating obscure
KDLs...
2019-08-04 15:52:01 -04:00
Autocomitter
7739bbedf8 Update translations from Pootle 2019-08-04 08:05:05 +00:00
Augustin Cavalier
287428271d kernel/condition_variable: Acquire and release locks in the right order.
Should fix #15223.
2019-08-03 20:31:41 -04:00
Augustin Cavalier
2f1e2ae469 kernelland_emu: Adapt to new ConditionVariable API.
This could use some optimizations, but it's only used by
userlandfs for now.
2019-08-03 11:46:05 -04:00
Augustin Cavalier
37eda488be kernel/condition_variable: Granularize locking.
Before this commit, *all* ConditionVariable operations (yes, all;
even Wait, Notify, etc.) went through a single spinlock, that also
protected the sConditionVariableHash. This obviously does not scale
so well with core count, to say the least!

With this commit, we add spinlocks to each Variable and Entry.
This makes locking somewhat more complicated (and nuanced; see
inline comment), but the trade-off seems completely worth it:

(compile HaikuDepot in VMware, 2 cores)
before
real 1m20.219s
user 1m5.619s
sys  0m40.724s

after
real 1m12.667s
user 0m57.684s
sys  0m37.251s

The more cores there are, the more of an optimization this will
likely prove to be. But 10%-across-the-board is not bad to say
the least.

Change-Id: I1e40a997fff58a79e987d7cdcafa8f7358e1115a
2019-08-03 11:24:34 -04:00
Augustin Cavalier
489612d43f kernel/condition_variable: Reorder some methods.
This way the static functions (used only in KDL) are below
the actual notification methods, which are now all grouped
together in one place.

No functional change.
2019-08-03 11:12:06 -04:00
waddlesplash
6cb38c6319 low_resource_manager: Do not spin forever during critical low resource conditions.
Since this thread has a very high priority, this causes the whole system
to lock up, making recovery from such a critical condition even more
impossible. Instead use the Warning-level timeout instead (0.3 seconds),
and of course we will be notified via the semaphore if something occurs
we should know about.
2019-08-02 22:18:56 -04:00
Ryan Leavengood
47df2afbf8 ShowImage: Wrap to first image when going next on last image
I find this handy and in addition it makes the slide show cyclic again,
fixing #10386.

Going the other way might also be useful, but that requires some additions to
the Navigator code first.
2019-08-02 21:27:14 -04:00
Augustin Cavalier
677e901f80 kernel/module: Utilize RecursiveLocker. 2019-08-02 21:06:09 -04:00
Augustin Cavalier
afb345915d linkcatkeys: Avoid discarding potential error values.
Spotted by Clang and the [[nodiscard]] patch.
2019-08-02 21:06:09 -04:00
Augustin Cavalier
dfbf1c8a0a Package Kit: Avoid discarding potential error values.
Spotted by Clang and the [[nodiscard]] patch.
2019-08-02 21:06:09 -04:00
Augustin Cavalier
a4a538db9f ACPI: Avoid discarding a potential error value.
This is part of a new diagnostic I've managed to wire up
that finds all instances of "status_t" function return
values being discarded using attribute trickery and some
creative Clang pragmas. As you might guess, the resultant
errors list is absolutely gigantic, and most of them are
ones where the failure condition will never (that we care
about) be hit.

The ones in this commit likely are no-op changes, but
they were low-hanging fruit spotted while reviewing
the larger list. The next commit will bring more
substantial changes.
2019-08-02 21:06:09 -04:00
CodeforEvolution
2846db2e99 Implement is_app_showing_modal_window()
Also do some cleanup in private headers, I can't imagine why the build
libraries would need this function.

Change-Id: Ib08810b6efe4738dad596a735d741582a3781b28
Reviewed-on: https://review.haiku-os.org/c/1670
Reviewed-by: Ryan Leavengood <leavengood@gmail.com>
2019-08-03 00:41:10 +00:00
Adrien Destugues
4534d86d21 PVS V781: size used before it's checked
memcpy with a negative parameter doesn't look like a great idea.

Change-Id: I3d1a8c224bd288784f068086652a84b2b75fcea8
Reviewed-on: https://review.haiku-os.org/c/1671
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-08-03 00:40:22 +00:00
Ryan Leavengood
5e7114c1e4 Tracker: Do a duplicate when pasting files into their own directory
Fixes #2755 (blast from the past!)

Change-Id: I5faff0563ca8c65cd78c8d1414517a652223d0fd
Reviewed-on: https://review.haiku-os.org/c/1673
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-08-03 00:39:05 +00:00
Ryan Leavengood
7451b647db StyledEdit: draw the status bar with the panel text color
Hopefully this is the last piece of #4868.
2019-08-02 19:49:59 -04:00
Ryan Leavengood
ecba7b5c7e Tracker: Ensure loading the Node works before passing to a Filter
Checking errors is important. This properly fixes #10365 and resolves a few
TODOs.

This DirectoryFilter is also used in Expander, though with a lower level
implementation that did not trigger this bug. This feels like it could be
in the the Tracker or shared kit.

Change-Id: Icd2ddc241c1879a7c4235726bf089570ba00dc0a
Reviewed-on: https://review.haiku-os.org/c/1672
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-08-02 04:31:43 +00:00
Alexander von Gluck IV
925d9f1909 build/scripts: Add find_triplet to allow easy solving of arch to gcc triplet 2019-08-01 10:36:01 -05:00
Augustin Cavalier
10d876dede Tracker: Add missing close-paren from previous commit. 2019-07-31 18:29:22 -04:00
Adrien Destugues
5bc378608a PVS V1039: useless use of multichar constants
Bitshifts and masks are a lot more readable here.

Change-Id: I94c8603b75d42456843a0b53bf2a0547aaffdb74
Reviewed-on: https://review.haiku-os.org/c/1669
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-31 22:00:53 +00:00
Adrien Destugues
0bc2edbd01 ScreenMode: add some manufacturers
Taken from http://edid.tv/manufacturer/

Mostly so my laptop properly identifies as Seiko Epson.

Change-Id: Ie04cb6593e87f3509a7158948d5ae85b10148fcb
Reviewed-on: https://review.haiku-os.org/c/1668
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-31 22:00:53 +00:00
Augustin Cavalier
69a9cd36e6 kernel/fs: Free file descriptors via put_fd(), not free().
FDs are now object_cached, so this triggered an assert-failure panic
trying to put them through the regular allocator. Just use put_fd
to free these instead, so that there is only one "destruction" path
for FDs.

Fixes #15213.
2019-07-30 23:42:20 -04:00
Augustin Cavalier
399fe9fc1a app_server: Alphabetize new include in MessageLooper. 2019-07-30 23:41:09 -04:00
Adrien Destugues
103741882a PVS V542: operator precedence issue accross macro expansion
In CodyCam, we attempt to cast the result of this macro to const char*.
However, the ternary operator has lower priority than the cast so it
doesn't work as expected.

Add some protective parentheses here.

Change-Id: I5e9875187cec67b9534b1bbe58d82217c6cd5524
Reviewed-on: https://review.haiku-os.org/c/1667
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-31 02:13:01 +00:00
Adrien Destugues
e1633b4220 PVS V536: accidentally octal constant
This bug was inherited from the original XScreenSaver sourcecode:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=575279#10

And is now fixed there:
https://github.com/Zygo/xscreensaver/blob/master/utils/yarandom.c
Change-Id: I08f2d968b76cd0b86291695e2f05e2173c972d05
Reviewed-on: https://review.haiku-os.org/c/1666
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-31 02:13:01 +00:00
Adrien Destugues
679c751309 PVS V529: ; after while
Just rewrite the loop in a more readable way.

Change-Id: I174016eac74eb54a01e5226b5f8a92fb1b335830
Reviewed-on: https://review.haiku-os.org/c/1665
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-31 02:13:01 +00:00
Adrien Destugues
e66c5b32a8 PVS V523: identical code in if/else
Use #if 0 to disable code that should be disabled.

Change-Id: I797383eb8c68681459d8cd56d1b3addda960fa44
Reviewed-on: https://review.haiku-os.org/c/1664
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-31 02:13:01 +00:00
Murai Takashi
cbc96724ab Localize AutoRaise
Change-Id: I3d71aa0691c4d8a59b6e8d4dbb2d7d4e7eab47c9
Reviewed-on: https://review.haiku-os.org/c/1659
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-31 02:11:19 +00:00
Alexander von Gluck IV
459b9916b9 nvme_disk: Disable Boot Symlink on non-x86; #15212 2019-07-30 13:39:19 -05:00
Alexander von Gluck IV
de4406ad8d nvme_disk: Disable on non-x86; #15212
* There are some type-length issues on arm, and our
  usage outside of x86 is limited for the moment.
* This could be fixed in the future.
2019-07-30 11:41:11 -05:00
Adrien Destugues
017d6fb4ad PVS V510: passing struct instead of address to function
Change-Id: Ic81e062e7ddb0d5ea2ef796bb0815f5ec6bf7414
Reviewed-on: https://review.haiku-os.org/c/1660
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-29 21:32:05 +00:00
Adrien Destugues
7bdc1a190c PVS V522: PathMonitor: NULL pointer dereference
Change-Id: I77df9c18960eee0183145441d3a1bd4ceb112147
Reviewed-on: https://review.haiku-os.org/c/1662
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-29 21:31:36 +00:00
Adrien Destugues
4950607607 Add a features.h to auto enable _DEFAULT_SOURCE
Unless __STRICT_ANSI__ is defined (as it is when running the compiler in
--std=c89 or --std=c99, but not when running it without any specific
args), we can enable these by default and behave like most other
systems. I don't know why no one has done this yet despite suggesting it
multiple times and people prefer to #define _BSD_SOURCE manually
everywhere.

Remove all places in our Jamfiles and sources where it had been defined.
_DEFAULT_SOURCE is now enabled by default for all sources of Haiku, since we
let the compiler use GNU extensions (no strict C standard specified on
command line)

Use _DEFAULT_SOURCE as the define name to match current versions of
glibc. Enable it if _BSD_SOURCE is #defined in compiler flags, for
backward compatibility.

Change-Id: I6db04da5f6db437723cdfba3478f5094a69d7727
Reviewed-on: https://review.haiku-os.org/c/1633
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2019-07-29 20:26:46 +00:00
Jérôme Duval
70e55f0046 autoraise: fix debug build.
Change-Id: I8ee35807eab8252dcb2399734fc5831f2b50690f
Reviewed-on: https://review.haiku-os.org/c/1657
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-28 20:34:23 +00:00
Augustin Cavalier
14b62ae4da BFS: Make the log-flusher thread persistent.
Previously, a new log-flush thread was created every time there was
an idle transaction. Now we just release a semaphore for an
already-existing thread.

Change-Id: If788dbe17ef8e069ce12aa7b778626d051cce2d0
2019-07-28 16:29:02 -04:00
Augustin Cavalier
1bb19993c0 app_server: Include malloc.h to appease GCC2. 2019-07-28 15:31:11 -04:00
Augustin Cavalier
206846d0f5 fs_shell: Add stub wait_for_thread.
We already have a dummy spawn_kernel_thread, so this makes sense to add
(and will be required by the next commit.)

Change-Id: Ic46607d46dabc6fd46fcfc0b6f8da0ed9897cfc9
Reviewed-on: https://review.haiku-os.org/c/1650
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-28 19:15:07 +00:00
Augustin Cavalier
bae7a949c5 app_server: We must clone the name in MessageLooper().
A number of things that pass it in have it as a stack temporary.
2019-07-28 15:03:42 -04:00
Augustin Cavalier
1b333570b5 app_server: Use RW_LOCK_FLAG_CLONE_NAME in MultiLocker.
This behavior was always used by the semaphore-based MultiLocker,
and it seems a good chunk of code depends on this, so we need
to preserve the behavior.
2019-07-28 14:54:25 -04:00
Humdinger
f5cdaacd20 Minor GUI string changes
HaikuDepot: change BAlert title
DriveSetup: capitalize Mimes -> MIMEs
2019-07-28 20:09:54 +02:00
Jérôme Duval
b1a92c722b usb_serial: make buffers kernel-only for SMAP, see #15172.
Change-Id: I11ea1e18977331a513bf97f5ce885f608e9b573a
Reviewed-on: https://review.haiku-os.org/c/1654
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-28 12:21:58 +00:00