Commit graph

1465 commits

Author SHA1 Message Date
U. Artie Eoff
32b2baaf51 add_shm_format: check wl_array_add return value before deref
In wl_display_add_shm_format(), check the return value from
wl_array_add() before dereferencing it and assigning it a value.
Return the resulting pointer back to the caller.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:09 -08:00
U. Artie Eoff
02952d040c xcursor: don't proceed if XcursorImageCreate failed
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:09 -08:00
U. Artie Eoff
d6c6f2977d cursor: check for memory allocation errors
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:09 -08:00
U. Artie Eoff
7d96da1e65 cursor: free theme->name too
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:09 -08:00
U. Artie Eoff
c0218227fe resources-test: assert non-NULL return values
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:09 -08:00
U. Artie Eoff
22a4a95873 queue-test: assert non-NULL return values
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:08 -08:00
U. Artie Eoff
e0c58cea4e os-wrappers-test: assert closure is not NULL before invoking it
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:08 -08:00
U. Artie Eoff
5e096ccc94 event-loop-test: assert non-NULL results
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:08 -08:00
U. Artie Eoff
3a1be1e6fe connection-test: assert closure is not NULL before invoking it
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:08 -08:00
U. Artie Eoff
fcf5f06b7d array-test: assert wl_array_add result is not NULL
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:08 -08:00
U. Artie Eoff
f97df69ee2 shm: assert sigbus_data is not NULL before member access
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-01-15 10:46:08 -08:00
Jasper St. Pierre
8a781aef0e xwayland: Add .gitignore 2014-01-10 15:50:21 -08:00
chi ding
c102c20f01 Fix buffer overflow when serializing a closure object
Here is the JIRA page of this issue
https://bugs.tizen.org/jira/browse/TIVI-1889

Change-Id: I773a6d2d8f6fd02ff10c92450db1fa8a69544219
Signed-off-by: Chi Ding <chi.ding@mobica.com>
Closes: https://bugs.freedesktop.org/show_bug.cgi?id=65186
2014-01-09 14:27:52 -08:00
Adrian Negreanu
cd0dccd01e scanner: set errno=0 before strtol
POSIX says to set errno=0 before calling strtol since
the return value alne cannot tell a failure.

on ubuntu armel I get:

  ../src/wayland-scanner client-header < ../../protocol/wayland.xml > wayland-client-protocol.h
  <stdin>:1188: error: invalid integer (2)

Signed-off-by: Adrian Negreanu <adrian.m.negreanu@intel.com>
2013-12-17 10:57:52 -08:00
Kristian Høgsberg
01bde6319f configure.ac: Bump version to 1.3.91 for the alpha release 2013-12-16 23:51:12 -08:00
Kristian Høgsberg
1a58c7f211 client: Handle EINTR in wl_display_dispatch_queue()
Restart the poll() if we take a signal.  This is easily triggered in
an application that ends up blocking in eglSwapBuffers(), and causes EGL
to fail to allocate a back buffer.
2013-12-09 16:19:33 -08:00
Jonas Ådahl
09877f3231 doc: Fix spelling of parameters
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-09 15:50:01 -08:00
Jonas Ådahl
c30208f0b7 doc: Remove incorrect docmentation
The documentation was about wl_client_get_object(), not about
wl_resource_get_client().

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-12-09 15:43:04 -08:00
Neil Roberts
1521c62a31 client: Make wl_proxy_set_queue() with NULL revert to default queue
This will be useful in order to implement the
EGL_WL_create_wayland_buffer_from_image extension. The buffers created
within Mesa's Wayland platform are created using the the wl_drm object
as a proxy factory which means they will be set to use Mesa's internal
event queue. However, these buffers will be owned by the client
application so they ideally need to use the default event loop. This
function provides a way to set the proxy's event queue back to the
default.

krh: Edited from Neils original patch to just use wl_proxy_set_queue() with
a NULL argument instead of introducing a new function.
2013-12-04 17:01:01 -08:00
Pekka Paalanen
3b3e81f42e cursor: handle running out of buffer space
If posix_fallocate is available, use it to detect when we are running
out of buffer space.

Propagate the failure properly through the various functions, stopping
loading cursors but keeping the cursors that were already successfully
loaded.

This may result in an animated cursor not having all of its images, or a
cursor theme not having all of its cursors. When that happens, the
failure is NOT communicated to the application. Instead, the application
will get NULL from wl_cursor_theme_get_cursor() for a cursor that was
not loaded successfully. If an animated cursor is missing only some
images, the animation is truncated but the cursor is still available.

This patch relies on the commit "os: use posix_fallocate in creating
sharable buffers" for defining HAVE_POSIX_FALLOCATE.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-12-02 16:19:45 -08:00
Pekka Paalanen
011b695403 os: use posix_fallocate in creating sharable buffers
If posix_fallocate is available, use it instead of ftruncate. Unlike
ftruncate, when posix_fallocate succeeds, it guarantees that you cannot
run out of disk space, when later writing to the mmap()'ed file.

With posix_fallocate, if os_create_anonymous_file() succeeds, the
program cannot get a SIGBUS later from accessing this file via mmap. If
there is insufficient disk space, the function fails and errno is set to
ENOSPC.

This is useful on systems, that limit the available buffer space by
having XDG_RUNTIME_DIR on a small tmpfs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-12-02 16:18:59 -08:00
Kristian Høgsberg
5a019e38a1 Add -pthread to AM_CFLAGS to do the right thing when using threads
https://bugs.freedesktop.org/show_bug.cgi?id=71633
2013-11-23 12:24:43 -08:00
Lubomir Rintel
360dca517a connection: Error out if file descriptor was not received
Otherwise the tail of fds_in buffer would just shift beyond the beginning.
That confuses the actual request handler and results in a crash further on
due to corrupted tail.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
2013-11-21 22:01:48 -08:00
Jasper St. Pierre
40d057f2c9 wayland-server: Improve error messages for bad globals
A bug in Weston's toytoolkit gave me an hour of debugging headaches.
Improve the error messages that we send if a client requests an invalid
global, either by name or by version.
2013-11-19 13:26:32 -08:00
Jasper St. Pierre
148478323f Update .gitignore for protocol/ 2013-11-19 13:26:04 -08:00
Kristian Høgsberg
853c24e699 client: Introduce functions to allocate and marshal proxies atomically
The server requires clients to only allocate one ID ahead of the previously
highest ID in order to keep the ID range tight.  Failure to do so will
make the server close the client connection.  However, the way we allocate
new IDs is racy.  The generated code looks like:

  new_proxy = wl_proxy_create(...);
  wl_proxy_marshal(proxy, ... new_proxy, ...);

If two threads do this at the same time, there's a chance that thread A
will allocate a proxy, then get pre-empted by thread B which then allocates
a proxy and then passes it to wl_proxy_marshal().  The ID for thread As
proxy will be one higher that the currently highest ID, but the ID for
thread Bs proxy will be two higher.  But since thread B prempted thread A
before it could send its new ID, B will send its new ID first, the server
will see the ID from thread Bs proxy first, and will reject it.

We fix this by introducing wl_proxy_marshal_constructor().  This
function is identical to wl_proxy_marshal(), except that it will
allocate a wl_proxy for NEW_ID arguments and send it, all under the
display mutex.  By introducing a new function, we maintain backwards
compatibility with older code from the generator, and make sure that
the new generated code has an explicit dependency on a new enough
libwayland-client.so.

A virtual Wayland merit badge goes to Kalle Vahlman, who tracked this
down and analyzed the issue.

Reported-by: Kalle Vahlman <kalle.vahlman@movial.com>
2013-11-15 20:49:36 -08:00
Pekka Paalanen
81c57614d1 protocol: add sub-surfaces to the core
The sub-surface protocol was originally committed into Weston on May
10th, 2013, in commit 2396aec6842c709a714f3825dbad9fd88478f2e6. The
design for the protocol had started in the beginning of December 2012. I
think it is high time to move this into the core now.

This patch copies the sub-surface protocol as it was in Weston on Nov
15th, 2013, into Wayland. Weston gets a patch to remove the protocol from
there.

Sub-surface is a wl_surface role. You create a wl_surface as usual, and
assign it the sub-surface role and a parent wl_surface. Sub-surfaces are
an integral part of the parent surface, and stay glued to the parent.
For window management, a window is the union of the top-level
wl_surface and all its sub-surfaces. Sub-surfaces are not clipped to the
parent, and the union of the surface tree can be larger than the
(top-level) wl_surface at its root.

The representative use case for sub-surfaces is a video player window.
When the video content is given its own wl_surface, there is no need to
modify the video frame contents after decoding or copy them into a whole
window sized buffer before submitting it to the compositor. This allows
efficient, zero-copy video presentation paths, where video decoding
hardware produces a (YUV) buffer, which eventually ends up in a
(YUV-capable) hardware overlay and is scanned out directly.

This can also be used for zero-copy presentation of windowed OpenGL
content, where the OpenGL rendering engine does not need to draw or
avoid window decorations.

Sub-surfaces allow mixing different buffer types into the same window,
e.g. software-rendered decorations in wl_shm buffers, and live content
in EGL-based buffers.

However, the sub-surface extension does not offer clipping or scaling
facilities, or accurate presentation timing. Those are topics for
additional extensions.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2013-11-15 20:49:36 -08:00
Lubomir Rintel
4a196570a3 shm: Avoid file descriptor leak upon unsuccessful mmap
It would be possible to make the compositor leak file descriptors by
passing descriptors of open unmmapable files to it, such as /dev/null.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
2013-11-15 16:21:45 -08:00
Neil Roberts
c2bba88ccd Add documentation for wl_shm_buffer_begin/end_access
It's not obvious that these functions are needed so it would be good
to have some documentation for them.
2013-11-15 14:46:48 -08:00
Kristian Høgsberg
a71cf48ce0 scanner: Add location to elements so we can give better errors/warnings 2013-11-15 14:44:39 -08:00
Kristian Høgsberg
5a4dd76495 scanner: Make fail() function use va_list and elaborate a few errors 2013-11-15 14:44:39 -08:00
Kristian Høgsberg
db8ae8903f scanner: Introduce struct location for tracking source locations 2013-11-15 14:44:39 -08:00
Kristian Høgsberg
3470fa17b5 scanner: Warn about requests with more than one new-id and don't generate stubs
The generated code only support one new-id per request, since the stubs
return the new proxy.  It's still possible to send requests with multiple
new-id arguments, but it must be done with
wl_proxy_marshal_array_constructor().
2013-11-15 14:44:39 -08:00
Kristian Høgsberg
b583b54560 server: Start documenting the server side API
This is now public, stable API, so it seems prudent to actually document it.
2013-11-13 21:11:17 -08:00
Neil Roberts
cf4f5995dc server: Add API to protect access to an SHM buffer
Linux will let you mmap a region of a file that is larger than the
size of the file. If you then try to read from that region the process
will get a SIGBUS signal. Currently the clients can use this to crash
a compositor because it can create a pool and lie about the size of
the file which will cause the compositor to try and read past the end
of it. The compositor can't simply check the size of the file to
verify that it is big enough because then there is a race condition
where the client may truncate the file after the check is performed.

This patch adds the following two public functions in the server API
which can be used wrap access to an SHM buffer:

void wl_shm_buffer_begin_access(struct wl_shm_buffer *buffer);
void wl_shm_buffer_end_access(struct wl_shm_buffer *buffer);

The first time wl_shm_buffer_begin_access is called a signal handler
for SIGBUS will be installed. If the signal is caught then the buffer
for the current pool is remapped to an anonymous private buffer at the
same address which allows the compositor to continue without crashing.
The end_access function will then post an error to the buffer
resource.

The current pool is stored as part of some thread-local storage so
that multiple threads can safely independently access separate
buffers.

Eventually we may want to add some more API so that compositors can
hook into the signal handler or replace it entirely if they also want
to do some SIGBUS handling.
2013-11-13 16:31:28 -08:00
Peter Hutterer
05f95c85c8 protocol: validate the protocol against a dtd
The scanner is not very forgiving if the protocol doesn't match it's
expectations and crashes without much of a notice. Thus, validate the protocol
against a DTD.

Move the protocol subdir forward so we validate first before trying anything
else, and install the DTD so we can validate weston's protocols as well.
2013-10-25 10:58:06 -07:00
Kristian Høgsberg
16b2dab4e4 configure.ac: Bump version to 1.3.90 for the master branch 2013-10-23 09:25:08 -07:00
Kristian Høgsberg
deddea6549 wayland: Be consistent about #include-guard names
We had a mix of inconsistent names, some of which were non-conformant.
Standardize on all-uppercase-and-underscore naming convention.

https://bugs.freedesktop.org/show_bug.cgi?id=70679
2013-10-21 14:39:06 -07:00
José Bollo
84247b7513 protocol: Fix typo in documentation 2013-10-11 10:04:43 -07:00
Kristian Høgsberg
2c3dbb8903 configure.ac: Bump version to 1.3 2013-10-09 16:20:54 -07:00
Kristian Høgsberg
bb6f6faaa2 scanner: Handle unrecognized invocation mode
Print usage if we don't recognize the invocation mode.  Also fixes
uninitialized variable warning.
2013-10-07 21:36:31 -07:00
Kristian Høgsberg
260d73b449 configure.ac: Bump version to 1.2.92 2013-10-02 22:14:57 -07:00
Neil Roberts
799ea7206b client: Fix handling display->reader_count if poll fails
In wl_display_dispatch_queue, if poll fails then it would previously
return immediately and leak a reference in display->reader_count. Then
if the application ignores the error and tries to read again it will
block forever. This can happen for example if the poll fails with
EINTR which the application might consider to be a recoverable error.
This patch makes it cancel the read so the reader_count will be
decremented when poll fails.
2013-09-25 10:11:20 -07:00
Kristian Høgsberg
4125367f20 configure.ac: Bump version to 1.2.91 2013-09-22 14:12:26 -07:00
Jason Ekstrand
ba90497b87 Export the Wayland protocol XML file
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-09-21 21:48:56 -07:00
Marek Ch
b99edb8b7e tests: add wl_resource tests 2013-09-21 11:38:32 -07:00
Marek Ch
6f1569bd38 tests: add unit tests for wl_signal
Test wl_signal initialization, adding and getting listeners and emitting
2013-09-21 11:37:38 -07:00
Marek Ch
ec08c5c3e9 tests: extended message when leak in test is detected
When memory or fd leak is detected, print how many blocks of memory were
allocated and not freed, respectively how many files were opened/unclosed.
2013-09-21 11:36:33 -07:00
Chang Liu
5cf31443c5 client: fix an inconsistency in documentation
The errno is set to EAGAIN when there are undispatched events, according
to L1066 of wayland-client.c.
2013-09-21 11:34:57 -07:00
Aaron Faanes
5a92553237 doc: Slight tweaks to wl_listener
Prefer \comment over // in code blocks for consistency's sake and keep
variable definitions separated by a line from the rest of the body.
2013-09-21 11:31:50 -07:00