Commit Graph

59484 Commits

Author SHA1 Message Date
Augustin Cavalier
3256001041 runtime_loader: Reinit the heap lock after fork. 2018-12-18 18:01:09 -05:00
Murai Takashi
296120e005 MediaPlayer: Fix -Werror=format-truncation=
Increase size of text[], since snprintf() write to it max 66 bytes.
(sizeof(positionText)-1 + sizeof(" / ") + sizeof(durationText)-1 + 1 = 66)
Pointed out by gcc8.

Change-Id: Ic6ce221edb4ceff4b63c7b30d26c52d613cbb35e
Reviewed-on: https://review.haiku-os.org/779
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2018-12-18 18:37:14 +00:00
Humdinger
947124d152 Mail: Add queries for same subject, sender, recipient
In the "Queries" menu, add three items at the top to start a query
for the same recipient/sender/subject as the current email. Move the
separator and "Edit queries..." item to the bottom of the menu.

The temporarily created queries are put into B_USER_CACHE_DIRECTORY/Mail/.
The data in those queries might be private, therefore not in system /tmp.

The queries use the DefaultQueryTemplates for x-email, if that exists. This
is done by copying all the template's attributes. Code for that borrowed from
'copyattr'.

When creating a query for the same subject, use the MAIL:thread text for
the search, as that doesn't contain stuff like "Re: Re: Fwd: Re...". Do
the query for MAIL:subject though, because sent emails don't have a
MAIL:thread attribute.

Change-Id: I23b46f3ec07760d17b076d8b8aa8839c5f88963f
Reviewed-on: https://review.haiku-os.org/768
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2018-12-18 05:45:13 +00:00
Augustin Cavalier
5e621d3edd tests/posix: Add tls_concurrency_test.
From #14342. Crashed before the last commit, now works. Disabled because
it won't build under GCC2.
2018-12-17 20:09:27 -05:00
Augustin Cavalier
df3de4792e runtime_loader: Make the heap thread-safe.
Previously we didn't need to care about threading in here, as it
was used only up to the point where the application's _start was called
and then libroot's heap would take over. But with the introduction of TLS
support by pdziepak in 2014, we also handle TLS bookkeeping inside
runtime_loader, and so this heap needs to be thread-safe.

Properly fixes the JVM crashes korli was attempting to fix in hrev52658,
and fixes #13154, #14129, #14304, #14342 for real.
2018-12-17 20:03:47 -05:00
Augustin Cavalier
e7d37c7e08 Revert "runtime_loader: Add missing locking around resizing the TLS DTV."
This reverts commit d0111efead.

Initially, I, too thought this was the correct solution. In
investigating the related #14342, I found that adding a lock of
the mutex in the function that crashed most often in (DestroyAll())
increased the time it took to cause a crash from 1-2 seconds
to 10-15 seconds, but it still inevitably crashed.

Further, crash addresses were often very low (e.g. 0x1, 0x18); on
inspection I determined these were coming from the fPointer fields
of TLSBlocks. But accesses to TLSBlocks were now well protected
by the TLS mutex, and they were memset'd after allocation, so that
didn't make any sense.

At that point, I went back and read over the code until I understood
it, and it became clear this solution was incorrect: TLSBlocks and
their underlying data are always associated with a specific thread,
meaning _Resize() and DestroyAll() would never be called on the same
data from different threads, despite appearances to the contrary.

Thus despite a dearth of comments in this file, it seems pdziepak
knew what he was doing when he wrote this; no locking is needed.
That left only one place to cause this kind of memory corruption...
2018-12-17 19:52:49 -05:00
Augustin Cavalier
da31c58577 shared/locks: Add RecursiveLocker.
Copied from the kernel version.
2018-12-17 19:51:45 -05:00
Danc2
def61273ed net_server: Add (more) missing devices even if one has already been found.
Fixes #6423 and helps with #14626.

In BringUpInterfaces, line 772 creates an error which only adds a missing
interface if one does not already exist (i.e., !_testInterface()). This can lead to
a missing WiFi interface if an Ethernet connection has been configured and set in
the /boot/system/settings/network/interfaces before the WiFi has had a chance to
be added to /dev/net. To properly configure a missing device, such as a WiFi
connection, and allow the user to choose amongst configured interfaces (i.e.,
add it to the list of devices in /dev/net and e.g., see WiFi as an option),
removing the 'if' statement on line 772 is necessary.

Two edge cases may arise:
1. A user may disable an interface -- don't add device
Solution: The code currently handles this. _ConfigureInterfacesFromSettings, called
at line 746, checks for interfaces in fSettings to see if they are disabled (706-711).
If so, they are disabled and not set as a missingDevice if the interface is disabled
(709). The next interface is checked... etc.

2. Devices must not be added twice (i.e., Checking for An Existing configured Network)
Solution: The code currently checks for this. On lines 716-720, a device that is found
in fSettings (missingDevice), is set to the interface which is later added to the
/dev/net within that (unnecessary?) if statement (772). The missingDevice will only
be set and added to /dev/net if an entry does not exist in the settings already (716)
(hence the identifier missingDevice).
Change-Id: Ifc303371b88f18c30141a651a7d97a3c860e864f
Reviewed-on: https://review.haiku-os.org/767
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-12-17 22:46:08 +00:00
Andrew Lindesay
3369e03d5c HaikuDepot: Process and Data-loading Improvements
This change is a reshuffle of the backend processing involved in the
aquisition of data from servers including the pull-down and load of
HPKR data as well as the pull-down and load of data from the
HaikuDepotServer (HDS) system.  The driver for this change is to
implement an initial implementation of a progress bar for the
loading of data as the application starts.

The following are notable changes;

* Removed some previously attempted 'functional style' logic in the
  model which didn't fit well with C++
* Use of the base-url in the logical mapping from HDS and HD data is no
  longer required and has been removed
* Some logging has been improved making it clearer which part of HD
  is producing the logging which in turn helps with debugging issues
* List class has been modified to more cleanly support sorted lists
  and binary searches; tests have also be updated accordingly
* Reorganise and tidy-up of the data-loading processes' structures
* The local repository update (HPKR) and data-load occur in background
  processes now in the same system as the HDS data-load - this has been
  crudely shifted from the MainWindow to new Processes and incorporated
  into the background processing system
* The 'state-machine' background process runner is now replaced with a
  'coordinator' style approach that can more easily handle the new
  processes related to HPKR loading.
* Progress for loading processes is shown in the main window in the
  WorkStatusView - this is flickering a bit, but basically works
* Added some documentation regarding how Processes work in the system
* The "Refresh Repositories" menu item now also updates data from HDS
* The "Refresh Repositories" menu item is disabled when the background
  processes are running that update the repository data

Some further refinement would be good, but this change is large enough
for one round of improvements.  There is an issue that the status bar
is used for screenshot display as well as this data-loading, but that
was the case before so it is something that can be dealt with later if
it is a problem.

Change-Id: I7668307645e3aabaf7e4a6e37e2cca80cc0f489e
Reviewed-on: https://review.haiku-os.org/770
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-12-17 19:31:25 +00:00
Owen
1609bb2f67 Mail: Fix infinite loop in FindURL.
Fixes #14746.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
One minor change from owenca's original patch: we can't return
immediately if urlString is NULL, as the caller probably wants
the urlLength.
2018-12-17 13:45:33 -05:00
Jérôme Duval
d0111efead runtime_loader: Add missing locking around resizing the TLS DTV.
* Fixes crashes when the DTV is concurrently resized by multiple threads.
* Fixes JVM crash or endless loop when building OpenJDK.
* Should help with #13154, #14129, #14304, #14342.

Change-Id: I132600315d76a1a86236c6c70db09a3cdf0a8743
Reviewed-on: https://review.haiku-os.org/771
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
2018-12-17 18:20:45 +00:00
Augustin Cavalier
6109c51d55 idualwifi7260: Add another NULL check before memset. 2018-12-16 22:51:49 -05:00
Augustin Cavalier
a07f133e5b KPath: Prevent setting a KPath to itself causing use-after-free.
SetTo frees the buffer before setting it to the new one,
but if KPath sets itself to ... itself, then it will of course
try to access the buffer again.

Spotted by clang-analyzer (amidst quite a few false positives,
so this doesn't seem like an especially good rabbit hole
to go down right now.)
2018-12-16 22:29:29 -05:00
Augustin Cavalier
a41ed241d9 headers/compatibility: Re-add missed _BSD_SOURCE guards to vis.h 2018-12-16 21:01:03 -05:00
Augustin Cavalier
514bace91d keymap: Allocate BApplication on the heap.
Avoids triggering an assert at program exit.
2018-12-16 19:35:04 -05:00
Augustin Cavalier
324336d1ed libbsd: Update vis and unvis from FreeBSD.
Fixes #11061.
2018-12-16 18:32:55 -05:00
Augustin Cavalier
18016b9654 broadcom440x: Add missing NULL check.
Fixes #4293 (again.)
2018-12-16 17:14:46 -05:00
Humdinger
b3fd8cd82a TextSearch: don't hard-code Pe editor
When double-clicking a result in TextSearch, it opens the file with
the preferred application for that file type. In case you search
through e.g. a HTML file, that would be most probably WebPositive,
which is not what you want normally.

TextSearch has the setting "Open files in Pe" which forces all files
to be opened in the Pe editor.

With this change, it will force the files to be opened in the
preferred app for text/x-source-code.

Change-Id: I0920a5f2497c01b16be0ac7563fbab942b67ef24
Reviewed-on: https://review.haiku-os.org/769
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-12-16 17:36:19 +00:00
Augustin Cavalier
9effbd7e00 Remove some unused cruft from the early days.
These lines were added in 2002...
2018-12-15 20:26:13 -05:00
Augustin Cavalier
707c912e12 Tracker: Remove "launch broken link" cruft.
As the comment says, this was a pre-R5 (!) hack for Be's CIFS driver.
2018-12-15 18:11:20 -05:00
Augustin Cavalier
a99aa113de Installer: Check return value of system() calls.
Solves a TODO.
2018-12-15 17:52:23 -05:00
Augustin Cavalier
72fa4a2e5e Installer: Check return value of GetMountPoint.
Probably fixes #14586 (NULL dereference in the strcmp on the next line)
but I couldn't quite manage to reproduce it.
2018-12-15 17:52:08 -05:00
Augustin Cavalier
414b21c497 docs/user: Fix description of bigtime_t. 2018-12-14 18:59:17 -05:00
Augustin Cavalier
901de869a3 BDirectory: Rewrite some functions for clarity.
No functional change intended. Whoever wrote these functions before
seems to have been allergic to more than one "return" statement
in a function...
2018-12-14 18:56:53 -05:00
Augustin Cavalier
26d14a317c BDirectory: GetNextEntry() should unset entry when one is not found.
Fixes #1692.
2018-12-14 18:48:38 -05:00
Murai Takashi
e000ae2c88 bin/notify: Fix PVS 741
Fix 'bitmap' is assigned values twice successively.

Change-Id: I02d70a581a682607f6ed280b71cc33c54738b343
Reviewed-on: https://review.haiku-os.org/766
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2018-12-14 22:52:42 +00:00
Murai Takashi
e3af9ff0bf kits/tracker: Fix PVS 923
Fix 'entry' is assigned values twice successively.

Change-Id: I86456bf156eb48f3966439a854256e27ee87caaf
Reviewed-on: https://review.haiku-os.org/765
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2018-12-14 22:52:42 +00:00
Murai Takashi
3fb9ab7fb6 bus_managers/firewire: Fix PVS 396
Fix 'info' is assigned values twice successively.

Change-Id: I981d3176a41a5f7616ef5a20dae889f1f01525bd
Reviewed-on: https://review.haiku-os.org/764
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2018-12-14 22:52:42 +00:00
Adrien Destugues
16a54a87fd Merge usb_floppy back into usb_disk.
- USB pen drive seems to still work. More extensive testing welcome.
- USB floppies don't work yet, but they don't work anymore with the
  current driver, either. I'm still investigating that part.

Fixes #9276

Change-Id: I8aa5ab828ad2ad867d0c187062d6e179372fc2ad
Reviewed-on: https://review.haiku-os.org/747
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-12-14 22:51:44 +00:00
Peter Kosyh
6fa279737e IMAP: sync fixes
This patch should fix:

- deadlocks while manual syncing/shutdown;
- crashes while manual syncing/shutdown.

Change-Id: I0962ff5580c19cbf740d002b6f62681ed5f558ab
Reviewed-on: https://review.haiku-os.org/758
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
2018-12-13 09:32:35 +00:00
Augustin Cavalier
e7e7a55250 kernel/fs: Account for vnode being NULL in vfs_release_posix_lock.
When the FD is put() but not freed while O_DISCONNECTED, its "ops"
and "vnode" are cleared. Thus it is entirely valid for a non-NULL
file FD to have a NULL vnode, so we should just treat such FDs
as if the locks had already been cleared (which they should have.)

Fixes #14294.
2018-12-12 19:24:59 -05:00
Augustin Cavalier
bee962a25e kernel/fs: Consumers of context->fds[] must check O_DISCONNECTED.
Since these do not go through get_fd, which would check for them,
we need to do these checks manually in the relevant locations.

Some of these changes were broken out from axeld's original commit,
and some were found by my own auditing.
2018-12-12 19:05:14 -05:00
Augustin Cavalier
64d1636fea kernel: Rework the FD disconnect feature (again).
axeld's solution from 2015 worked in that it solved the panics and
problems with leaking FDs ... but only if nobody actually tried to
use the FDs again. As you can see in the diff of the previous commit,
in allowing closed FDs (which have NULL "ops") to be returned by get_fd,
all consumers of the get_fd API (so, pretty much most functions in
vfs.cpp and fd.cpp) have to check *both* that (1) the fd is not NULL,
and (2) the fd does not have O_DISCONNECT set.

Besides missing a large majority of consumers of get_fd (which caused
ticket #14532 and also the first half of ticket #14756, probably among
others, as I haven't reviewed all NULL-dereference-in-VFS tickets yet)
this solution missed the fact that calling get_fd increments the reference
count, but then exiting the exact same way as if the FD was NULL
(without putting it) when it is disconnected *also* leaks the FD.

As it turns out, a not insignificant number of applications try
to do this, which (depending on whether you went through one of the
'lucky' functions axeld's commit touched) either (1) leaked the FD,
or (2) caused a kernel panic.

Now, we could go through and add O_DISCONNECT checks to every single
consumer of get_fd followed by put_fd to get the proper behavior ...
but that would be the same thing as just returning NULL here and not
incrementing the reference count.

So it seems the first part of axeld's solution (don't set open_count
or ref_count to -1 but leave them as-is) is the only change necessary.

A few places where there were legitimately missing O_DISCONNECT checks
(some originally added by axeld) are (re-)added in the next commit.
Otherwise this seems to be the more robust solution. (But I wonder why
nobody caught this in the code review axeld asked for in the commit
and the ticket back in 2015? Did nobody notice the unbalanced get/put?)

Fixes #14532, part of #14756, and probably any other NULL dereferences
in VFS I/O functions (XHCI is especially good at exposing these)
that are lingering around on the bugtracker.
2018-12-12 18:42:03 -05:00
Augustin Cavalier
15ec0b5cc8 Revert "VFS: Slight rework of the FD disconnect feature."
This reverts commit eb62d3337b.
2018-12-12 18:40:04 -05:00
Augustin Cavalier
675e5dfcac Mandelbrot: GCC2 fix. 2018-12-12 18:13:18 -05:00
kerwizzy
e5aeaa8d03 Mandelbrot: Implement subsampling
* Added subsampling. This makes the render look less noisy and generally nicer.

Change-Id: I1dd667c8799bd97fb84e1401976da12ecf74ea8c
Reviewed-on: https://review.haiku-os.org/732
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-12-12 22:17:24 +00:00
Murai Takashi
2e7e161dfb drivesetup: Fix PVS 832
Fix 'parentRow' is assigned values twice successively.

Change-Id: I57a1dec60f651c49eb05f3038b62c49c29eb2ff0
Reviewed-on: https://review.haiku-os.org/763
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-12-12 22:07:19 +00:00
Murai Takashi
9d9ca63110 glibc: Fix -Wheader-guard
Fix typo in header guard, pointed out by clang.
See also https://sourceware.org/git/?p=glibc.git;a=commit;h=9947638d74f490b8ec9a1563c195881a4151bd80

Change-Id: I6e01c67ed246d4be48463abc490bbb9ba4c76342
Reviewed-on: https://review.haiku-os.org/762
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2018-12-12 22:06:23 +00:00
Murai Takashi
382eca52a2 zipomatic: Fix PVS 1103
Fix 'status' is assigned values twice successively.

Change-Id: I348799db32342f0642dac89a62a518d21ef11c34
Reviewed-on: https://review.haiku-os.org/761
Reviewed-by: Barrett17 <b.vitruvio@gmail.com>
2018-12-12 21:31:56 +00:00
Murai Takashi
b6766af3e6 cortex: Fix PVS 1504
Fix 'r' is assigned values twice successively.

Change-Id: Ia46786badb1235f16c42e09eb9e9fb750fb2bf29
Reviewed-on: https://review.haiku-os.org/760
Reviewed-by: Barrett17 <b.vitruvio@gmail.com>
2018-12-12 21:31:53 +00:00
Augustin Cavalier
67f185ecf5 kernel: Don't retry or wait for the low_resource handler.
As axeld pointed out on the mailing list, map_backing_store is called
with the address space write-locked, and so the resources won't be
released until after we return.

Due to the state we are in at this point, unlocking the address space
before making this call would be likely be very dangerous, and so
simply issuing the notification and then returning an error is all
we can safely do here.
2018-12-12 10:55:43 -05:00
Murai Takashi
07af264afa ipv4: Fix PVS 2464
Fix using local variable within a loop with a same name
as a variable controlling this loop.

Change-Id: Ie920807a56e51b32844ac13ff1d8c564466d3a83
Reviewed-on: https://review.haiku-os.org/751
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2018-12-11 19:51:20 +00:00
Augustin Cavalier
f1e8678942 kernel: Notify low resource handler & retry when low on kernel address space.
Solves a decade-old TODO. This might help with strange behavior in
low-memory conditions.
2018-12-11 14:44:52 -05:00
Augustin Cavalier
0a347c90d5 kernel: Minor style cleanup to arch_altcodepatch.
No functional change intended.
2018-12-11 13:38:13 -05:00
Augustin Cavalier
8a1709b3af vm: Allow W|X before kernel startup ends.
The altcodepatch mechanism needs to overwrite parts of the kernel
image. This can't be done by setting it to RW-only and not RWX,
as we are already running within the kernel when this occurs,
and so instruction fetches can and will occur between the points
of +W and -W.

As gKernelStartup is turned off before the scheduler is started,
this is not much of a lifted restriction, as no modules are loaded,
no secondary threads started, etc.

Fixes #14751.
2018-12-11 13:37:39 -05:00
Augustin Cavalier
08858e10fa kernel_cpp: Don't import all of the "std" namespace.
This file is included, directly or indirectly, by most of the
kernel-space C++ code, and so importing the entirety of "std"
seriously pollutes the global namespace.

So instead, just import "std::nothrow", which is the only thing
we really want in the global namespace. Tested on both GCC2
and GCC7 and seems to work just fine.

While I'm here, also update the include guards and copyright
header to match the standard format used elsewhere.
2018-12-10 19:44:07 -05:00
Augustin Cavalier
cac9cf1565 kernel: Staticize id_generator's GeneratorList object.
Spotted by Clang.
2018-12-10 19:17:08 -05:00
Augustin Cavalier
8844a67e90 More trivial syntax and logic cleanup.
Spotted by Clang. No functional change intended.
2018-12-10 19:16:19 -05:00
Alexander von Gluck IV
b279d6def1 busses/mmc/sdhci_pci: Return B_UNHANDLED_INTERRUPT at end of non-void func
* I'm making an assumption here this is the desired result since interrupts
  are unhandled at the end of the function.
* Pointed out by gcc
2018-12-10 16:01:07 +00:00
Augustin Cavalier
4089701dbd interface: Remove some unreachable "break"s.
Spotted by Clang.
2018-12-09 23:04:45 -05:00