summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* client: fix wl_display_disconnect() documentationSimon Ser2023-03-071-2/+3
| | | | | Signed-off-by: Simon Ser <contact@emersion.fr> Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/361
* client: Do not warn about attached proxies on default queue destruction.Alexandros Frantzis2023-03-011-5/+9
| | | | | | | | | | | | | | If the default queue is being destroyed, the client is disconnecting from the wl_display, so there is no possibility of subsequent events being queued to the destroyed default queue, which is what this warning is about. Note that interacting with (e.g., destroying) a wl_proxy after its wl_display is destroyed is a certain memory error, and this warning will indirectly warn about this issue. However, this memory error should be detected and warned about through a more deliberate mechanism. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
* client: Abort when trying to add an event to a destroyed queueAlexandros Frantzis2023-02-281-0/+5
| | | | | | | | | | Detect when we are trying to add an event to a destroyed queue, and abort instead of causing a use-after-free memory error. This situation can occur when an wl_event_queue is destroyed before its attached wl_proxy objects. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
* client: Warn when a queue is destroyed with attached proxiesAlexandros Frantzis2023-02-281-0/+16
| | | | | | | Log a warning if the queue is destroyed while proxies are still attached, to help developers debug and fix potential memory errors. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
* client: Track the proxies attached to a queueAlexandros Frantzis2023-02-281-0/+22
| | | | | | | | Maintain a list of all wl_proxy objects that are attached to a wl_event_queue. We will use this information in upcoming commits to warn about improper object destruction order that can lead to memory errors. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
* shm: fix segfault when accessing destroyed pool resourceSimon Ser2023-02-271-4/+6
| | | | | | | | | | | With wl_shm_buffer_ref_pool(), it's possible for a wl_shm_pool to outlive its wl_resource. We need to be careful not to access wl_shm_pool.resource if it's been destroyed. Reset resource to NULL in the resource destroy handler, and add NULL checks. Signed-off-by: Simon Ser <contact@emersion.fr>
* wayland-server: Add method to get global nameAndri Yngvason2023-02-112-0/+21
| | | | | | | This is useful for protocol designs where globals need to be referenced in some manner. Signed-off-by: Andri Yngvason <andri@yngvason.is>
* server: rename wl_display.id to next_global_nameSimon Ser2023-01-251-4/+4
| | | | | | | This is much more descriptive. This value is a counter incremented each time a new global is created. Signed-off-by: Simon Ser <contact@emersion.fr>
* server: fail on global name overflowSimon Ser2023-01-251-0/+5
| | | | | | | | | display->id is initialized to 1, making 0 a convenient value to indicate an invalid global name. Make sure to not return a zero global name on overflow. Moreover, if we wrap around, we might cycle back to a global name which is already in-use. Signed-off-by: Simon Ser <contact@emersion.fr>
* scanner: Fix undefined behavior around qsortFergus Dall2023-01-031-2/+7
| | | | | | | | | According to clang, qsort cannot be passed a null pointer, even if the size is specified to be zero. The scanner can hit this while trying to sort forward declarations if it happens to be building a protocol file that doesn't require any, either in the header or the source. Signed-off-by: Fergus Dall <sidereal@google.com>
* wayland-server: Add wl_client_add_destroy_late_listenerDaniel Stone2022-10-202-0/+50
| | | | | | | | | | A late-destroy listener for a client is called after all the client's resources have been destroyed and the destroy callbacks emitted. This lives in parallel to the existing client destroy listener, called immediately before the client's objects get destroyed. Signed-off-by: Daniel Stone <daniels@collabora.com> Fixes: wayland/wayland#207
* server: don't document void return valuesSimon Ser2022-09-131-2/+0
| | | | | | | | | Fixes the following warnings: src/wayland-server.c:1152: warning: documented empty return type of wl_display::wl_display_destroy src/wayland-server.c:1193: warning: documented empty return type of wl_display::wl_display_set_global_filter Signed-off-by: Simon Ser <contact@emersion.fr>
* util: name function typedef argumentsSimon Ser2022-09-131-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Doxygen doesn't support documenting unnamed function arguments. Fixes the following warnings: src/wayland-util.h:697: warning: argument 'const' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'void' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'void' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'uint32_t' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'const' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'struct' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'wl_message' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'union' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'wl_argument' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:725: warning: argument 'const' of command @param is not found in the argument list of wl_log_func_t(const char *, va_list) src/wayland-util.h:725: warning: argument 'char' of command @param is not found in the argument list of wl_log_func_t(const char *, va_list) src/wayland-util.h:725: warning: argument 'va_list' of command @param is not found in the argument list of wl_log_func_t(const char *, va_list) src/wayland-util.h:697: warning: argument 'const' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'void' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'void' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'uint32_t' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'const' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'struct' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'wl_message' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'union' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:697: warning: argument 'wl_argument' of command @param is not found in the argument list of wl_dispatcher_func_t(const void *, void *, uint32_t, const struct wl_message *, union wl_argument *) src/wayland-util.h:725: warning: argument 'const' of command @param is not found in the argument list of wl_log_func_t(const char *, va_list) src/wayland-util.h:725: warning: argument 'char' of command @param is not found in the argument list of wl_log_func_t(const char *, va_list) src/wayland-util.h:725: warning: argument 'va_list' of command @param is not found in the argument list of wl_log_func_t(const char *, va_list) Signed-off-by: Simon Ser <contact@emersion.fr>
* server: Extend display name string sizeCarlos Garnacho2022-08-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | Typically this is a number between 0 and 32. Just that the compiler doesn't know that well. Make the string buffer a bit larger, so that it fits the longer integers. Fixes build warnings like: ../subprojects/wayland/src/wayland-server.c: In function ‘wl_display_add_socket_auto’: ../subprojects/wayland/src/wayland-server.c:1649:70: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Werror=format-truncation=] 1649 | snprintf(display_name, sizeof display_name, "wayland-%d", displayno); | ^~ ../subprojects/wayland/src/wayland-server.c:1649:61: note: directive argument in the range [-2147483647, 32] 1649 | snprintf(display_name, sizeof display_name, "wayland-%d", displayno); | ^~~~~~~~~~~~ ../subprojects/wayland/src/wayland-server.c:1649:17: note: ‘snprintf’ output between 10 and 20 bytes into a destination of size 16 1649 | snprintf(display_name, sizeof display_name, "wayland-%d", displayno); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Seen in GTK CI. Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
* Document which type are nullable, and wire format for null valueIan Douglas Scott2022-07-141-1/+1
| | | | Signed-off-by: Ian Douglas Scott <idscott@system76.com>
* Do not allow nullable `new_id`Ian Douglas Scott2022-07-142-3/+2
| | | | | | | | The usefulness of this is limited, and `libwayland-client` doesn't provide a way to pass a null `new_id` since the id is generated by the library and given to the caller as the return value. Signed-off-by: Ian Douglas Scott <idscott@system76.com>
* Do not allow nullable arrays, which were not correctly implementedIan Douglas Scott2022-07-142-3/+2
| | | | | | | | | | | Nullable arrays, which are not used anywhere, were marshalled the same way as an empty non-null array. The demarshalling logic did not recognize anything as a null array. Given this, it seems better to just explicitly not support it. Fixes https://gitlab.freedesktop.org/wayland/wayland/-/issues/306. Signed-off-by: Ian Douglas Scott <idscott@system76.com>
* util: set errno when hitting WL_MAP_MAX_OBJECTSSimon Ser2022-06-281-2/+7
| | | | | | | | | | | | Callers may check errno when wl_map_insert_* functions return an error (since [1]). Make sure it's always set to a meaningful value when returning an error, otherwise callers might end up checking an errno coming from a completely different function. [1]: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/205 Signed-off-by: Simon Ser <contact@emersion.fr> Fixes: b19488c7154b ("util: Limit size of wl_map")
* server: warn about global filtering consistencySimon Ser2022-06-151-0/+4
| | | | | | | | The filtering needs to be static given a client and a global, otherwise libwayland will misbehave. Signed-off-by: Simon Ser <contact@emersion.fr> References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/241#note_1421888
* server: add PID race condition disclaimer to wl_client_get_credentialsSimon Ser2022-06-151-0/+3
| | | | | | | PIDs are re-used and cannot be used to reliably check the identity of a Wayland client. Signed-off-by: Simon Ser <contact@emersion.fr>
* server: check visibility before sending global/global_removeSimon Ser2022-06-151-7/+9
| | | | | | | | | | | See the previous discussion at [1]: libwayland incorrectly skips the visibility checks when sending global/global_remove events. The check is only performed when a client performs a wl_display.get_registry request. [1]: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/148 Signed-off-by: Simon Ser <contact@emersion.fr>
* client: Lock display when setting a proxy event queueAlexandros Frantzis2022-06-091-0/+4
| | | | | | | | | | | | | | | | | | | Assignments to a wl_proxy's queue member are currently not synchronized with potential reads of that member during event reading/queuing. Assuming atomic pointer value reads and writes (which is a reasonable assumption), and using the documented best practices to handle event queue changes, a queue change should still be safe to perform. That being said, such implicitly atomic accesses are difficult to assess for correctness, especially since they do not introduce memory barriers. To make the code more obviously correct, and handle any potential races we are not currently aware of, this commit updates wl_proxy_set_queue() to set the proxy's event queue under the display lock (all other proxy queue accesses are already done under the display lock). Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
* client: Document best practices for event queue changesAlexandros Frantzis2022-06-091-0/+13
| | | | | | | | | | | | Document the proper way to deal with event queue changes, in order to guarantee proper handing of all events which were queued before the queue change takes effect, especially in multi-threaded setups. Make a special note about queue changes of newly created proxies, which require the use of a proxy wrapper for thread safety. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
* Check that XDG base directories paths are absoluteAntonin Décimo2022-06-092-5/+6
| | | | | | | | | | | | | | | | | | | The [spec][1] reads: > All paths set in these environment variables must be absolute. If an > implementation encounters a relative path in any of these variables it should > consider the path invalid and ignore it. and > If $XDG_DATA_HOME is either not set or empty, a default equal to > $HOME/.local/share should be used. Testing that the path is absolute also entails that is is non-empty. [1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
* Meson: Override wayland-scanner if it can be runXavier Claessens2022-05-241-0/+4
| | | | | | | This allows projects to use Wayland as a Meson subproject and get the wayland-scanner executable when doing find_program('wayland-scanner'). Signed-off-by: Xavier Claessens <xavier.claessens@collabora.com>
* util: fix code block language in docsSimon Ser2022-05-231-1/+1
| | | | | | | | | Without {.xml}, Doxygen interprets the code as C. See [1] for details. [1]: https://www.doxygen.nl/manual/commands.html#cmdcode Signed-off-by: Simon Ser <contact@emersion.fr>
* server: add wl_global_get_versionSimon Ser2022-05-232-0/+17
| | | | | | | | | Add a helper to check the advertised version of a global. This can be handy when checking whether a compositor feature is supported, instead of having to store the version passed to wl_global_create separately. Signed-off-by: Simon Ser <contact@emersion.fr>
* util: Limit size of wl_mapDerek Foreman2022-05-162-2/+24
| | | | | | | | | | | | | | | | | | | | Since server IDs are basically indistinguishable from really big client IDs at many points in the source, it's theoretically possible to overflow a map and either overflow server IDs into the client ID space, or grow client IDs into the server ID space. This would currently take a massive amount of RAM, but the definition of massive changes yearly. Prevent this by placing a ridiculous but arbitrary upper bound on the number of items we can put in a map: 0xF00000, somewhere over 15 million. This should satisfy pathological clients without restriction, but stays well clear of the 0xFF000000 transition point between server and client IDs. It will still take an improbable amount of RAM to hit this, and a client could still exhaust all RAM in this way, but our goal is to prevent overflow and undefined behaviour. Fixes #224 Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* build: sanity check optionsSimon Ser2022-05-101-0/+4
| | | | | | | | Fail when tests/documentation is enabled without libraries. Fail when neither scanner nor libraries is enabled, because we don't build anything in that case. Signed-off-by: Simon Ser <contact@emersion.fr>
* os: drop unnecessary memcpy in wl_os_mremap_maymoveSimon Ser2022-04-111-12/+13
| | | | | | | | | | | | | | FreeBSD doesn't support mremap [1], so we have a fallback implementation based on munmap+mmap. We memcpy from the old memory region to the new one, however this is unnecessary because the new mapping references the same file as the old one. Use msync to make sure any pending write is flushed to the underlying file before we map the new region. [1]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=59912 Signed-off-by: Simon Ser <contact@emersion.fr>
* shm: Close file descriptors not neededOlivier Fourdan2022-04-051-0/+8
| | | | | | | | | | | | | | | | | | | | | | | Commit 5a981ee8 implemented a fallback path for platforms which do not support mremap() such as FreeBSD. To do so, the file descriptor for the mmap() is not closed immediately but instead kept as long as the pool exists. That induces more file descriptors kept open for longer, which in turn may cause problems as wl_shm may be using a lot of file descriptors, especially with Xwayland which can create a lot of pixmaps on behalf of its X11 clients. For platforms where mremap() is available, keeping those file descriptors opened is a bit of a waste and may cause exhaustion of file descriptors sooner that before commit 5a981ee8. Only keep the mmap() file descriptor open on platforms which do not implement mremap() and close it immediately as before on others. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1283
* connection: change clen type in build_cmsg to size_tSigrid Solveig Haflínudóttir2022-04-031-2/+3
| | | | | | To avoid implicit conversion since msg_control's type is size_t. Signed-off-by: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
* connection: fix asan report on sendmsg callSigrid Solveig Haflínudóttir2022-04-031-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initialiaze the entire msghdr struct to 0 before use. Example of the report fixed with this change: AddressSanitizer:DEADLYSIGNAL ================================================================= ==20035==ERROR: AddressSanitizer: SEGV on unknown address 0x2dad4dbffffa0d (pc 0x0055555c7488 bp 0x007fffffc760 sp 0x007fffffc760 T0) ==20035==The signal is caused by a READ memory access. #0 0x55555c7488 in read_msghdr(void*, __sanitizer::__sanitizer_msghdr*, long) (/home/ftrvx/w/_/uxn/bin/uxnemu+0x77488) #1 0x55555c810c in sendmsg (/home/ftrvx/w/_/uxn/bin/uxnemu+0x7810c) #2 0x7ff7f2db20 in wl_connection_flush /home/ftrvx/q/wayland/build/../src/connection.c:315:10 #3 0x7ff7f2d014 in wl_display_flush /home/ftrvx/q/wayland/build/../src/wayland-client.c:2154:9 #4 0x7ff7e80bc0 (/lib/libSDL2-2.0.so.0+0x104bc0) #5 0x7ff7e523b0 (/lib/libSDL2-2.0.so.0+0xd63b0) #6 0x7ff7e534e4 (/lib/libSDL2-2.0.so.0+0xd74e4) #7 0x7ff7e535e8 (/lib/libSDL2-2.0.so.0+0xd75e8) #8 0x7ff7daad54 (/lib/libSDL2-2.0.so.0+0x2ed54) #9 0x7ff7dab130 (/lib/libSDL2-2.0.so.0+0x2f130) #10 0x555565bb40 in main /home/ftrvx/w/_/uxn/src/uxnemu.c:519:2 #11 0x7ff7f62484 in libc_start_main_stage2 /builddir/musl-1.1.24/src/env/__libc_start_main.c:94:2 AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV (/home/ftrvx/w/_/uxn/bin/uxnemu+0x77488) in read_msghdr(void*, __sanitizer::__sanitizer_msghdr*, long) ==20035==ABORTING Signed-off-by: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
* server: introduce wl_signal_emit_mutableSimon Ser2022-03-282-0/+66
| | | | | | | | | | | | | | | wl_signal_emit doesn't handle well situations where a listener removes another listener. This can happen in practice: wlroots and Weston [1] both have private helpers to workaround this defect. wl_signal_emit can't be fixed without breaking the API. Instead, introduce a new function. Callers need to make sure to always remove listeners when they are free'd. [1]: https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/457 Signed-off-by: Simon Ser <contact@emersion.fr> Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
* client, server: handle wl_map_insert_new() failuresAleksandr Mezin2022-03-252-3/+19
| | | | Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
* util: set errno in wl_map_insert_at()Aleksandr Mezin2022-03-253-9/+18
| | | | | | And add errno checks in callers, where it seems to be necessary. Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
* util: set errno in wl_map_reserve_new()Aleksandr Mezin2022-03-252-7/+17
| | | | | | And also fix wl_connection_demarshal() to pass through that errno. Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
* util: always check result of wl_array_add()Aleksandr Mezin2022-03-251-3/+7
| | | | | | | Not checking the result of wl_array_add() can cause writes past the end of the allocated buffer if realloc fails. Signed-off-by: Aleksandr Mezin <mezin.alexander@gmail.com>
* build: use get_variable(pkgconfig) instead of get_pkgconfig_variable()Simon Ser2022-03-251-1/+1
| | | | | | | We don't get a warning for it yet, but get_pkgconfig_variable() is deprecated. Signed-off-by: Simon Ser <contact@emersion.fr>
* connection: Make wl_closure_print output atomicAlexander Irion2022-03-081-16/+28
| | | | | | When multiple threads are used, output from different threads was intermixed in one line. That what breaking parsing of the log messages. Now, intermixing is prevented by using a memstream. Signed-off-by: Alexander Irion <alexander_irion@mentor.com>
* Use zalloc for structsSimon Ser2022-02-055-14/+14
| | | | | | | | When allocating memory for structs, use zalloc instead of malloc. This ensures the memory is zero-initialized, and reduces the risk of forgetting to initialize all struct fields. Signed-off-by: Simon Ser <contact@emersion.fr>
* meson: override dependencies to ease use as subprojectSimon Ser2021-12-081-0/+8
| | | | | | | | | | | | | Make it easier to use Wayland as a Meson subproject by overriding dependencies we define. This allows to easily build Wayland as a subproject like so: subproject('wayland', required: false, default_options: ['documentation=false']) After this statement, the wayland-* dependencies will use the subproject instead of the system if available. Signed-off-by: Simon Ser <contact@emersion.fr>
* wayland-shm: Check the size of sealed memory if ignoring SIGBUS handlersDuncan McIntosh2021-11-041-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | In 11623e8f, SIGBUS handlers aren't set if F_SEAL_SHRINK is configured on the memory. This helps avoid setting up handlers with cooperative clients; however, if an application gives an incorrect size, the compositor would access it anyways, figuring SIGBUS is impossible, and crash. This can be fixed by simply removing the seal-checking logic and always setting the signal handler. However, it seems that fstat can give the size of the memfd, so we can check that the size we were told is within the region. Since it's sealed to shrinking, it must never be shrunk in future, so we can really (hopefully) ignore SIGBUS. I was worried that fstat wasn't supported for this, but shm_overview(7) does mention that it is a possible use. The best solution would likely be avoiding SIGBUS entirely with MAP_NOSIGBUS, but that hasn't been merged yet and wouldn't help systems without it (e.g. with older kernels). A proof-of-concept of this crash is attached with the merge request. Running it with this patch gives an invalid-shm error, which is correct. Signed-off-by: Duncan McIntosh <duncan82013@live.ca>
* debug: Fix printing of new idsDerek Foreman2021-11-024-9/+29
| | | | | | | | | | | | | | | The client side closure traces have incorrect object ids for new server generated objects. This is because create_proxies() overwrites the id in 'n' type arguments by storing a pointer to the actual object in the 'o' field of the union. Getting back to an id from this pointer requires accessing a structure that isn't visible outside of wayland-client.c. Add a function pointer to fish the correct value out of the argument and pass it to wl_closure_print. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* build: Include the Wayland minor version in libraries' ABI versionsSimon McVittie2021-10-281-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ABI of a shared library on Linux is given by a major version, which is part of the SONAME and is incremented (rarely) on incompatible changes, and a minor version, which is part of the basename of the regular file to which the SONAME provides a symlink. Until now, the ABI minor version was hard-coded, which means we can't tell which of a pair of Wayland libraries is newer (and therefore likely to have more symbols and/or fewer bugs). libwayland-egl already had ABI major version 1, so we can use the "marketing" version number as the ABI major.minor version number directly, so Wayland 1.19.90 would produce libwayland-egl.so.1 -> libwayland-egl.so.1.19.90. libwayland-cursor and libwayland-server have ABI major version 0, and OS distributions don't like it when there's a SONAME bump for no good reason, so use their existing ABI major version together with the "marketing" minor version: libwayland-cursor.so.0 -> libwayland-cursor.so.0.19.90. If the Wayland major version number is incremented to 2, we'll have to rethink this, so add some error() to break the build if/when that happens. Assuming that Wayland 2.0 would involve breaking changes, the best way would probably to bump all the SONAMEs to libwayland-foo.so.2. Resolves: https://gitlab.freedesktop.org/wayland/wayland/-/issues/175 Signed-off-by: Simon McVittie <smcv@collabora.com>
* client: handle fcntl error on bad fd in wl_display_connectManuel Stoeckl2021-10-281-1/+3
| | | | | | | | This makes wl_display_connect fail immediately instead of succeeding when the integer provided by WAYLAND_SOCKET does not refer to a valid file descriptor. Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
* server: stop wl_display event loop from any contextDamian Hobson-Garcia2021-10-091-0/+44
| | | | | | | | | | | | | | | | | | | Calling wl_display_terminate() will exit the wl_display event loop at the start of the next loop iteration. This works fine when wl_display_terminate() is called after the event loop wakes up from polling on the added event sources. If, however, it is called before polling starts, the event loop will not exit until one or more event sources trigger. Depending on the types of event sources, they may never trigger (or may not trigger for a long time), so the event loop may never exit. Add an extra event source to the wl_display event loop that will trigger whenever wl_display_terminate() is called, so that the event loop will always exit. Fixes #201 Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp>
* shm: Relax shm_pool_create_buffer() validity checkOlivier Fourdan2021-09-161-1/+1
| | | | | | | | | | | | | | shm_pool_create_buffer() can raise a false WL_SHM_ERROR_INVALID_STRIDE error under some circumstances because of integer division. Fix this by using a strict comparison operator instead of lower or equal. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Demi Marie Obenour <demi@invisiblethingslab.com> Reviewed-by: Simon Ser <contact@emersion.fr> Reviewed-by: Jonas Ådahl <jadahl@gmail.com> Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/235
* Detect FreeBSD versions with broken MSG_CMSG_CLOEXECAlex Richardson2021-09-101-1/+10
| | | | | | | | If we are compiling against a version of FreeBSD where MSG_CMSG_CLOEXEC does not work, use the fallback directly. This was only fixed recently (in https://cgit.freebsd.org/src/commit/?id=6ceacebdf52211). Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
* shm: Add mmap+memmove fallback if mremap() does not existAlex Richardson2021-09-103-9/+73
| | | | | | | | | | Some operating systems (e.g. FreeBSD) do not implement mremap. In that case we can grow the mapping by trying to map adjacent memory. If that fails we can fall back to creating a new larger mapping and moving the old memory contents there. Co-authored-by: Koop Mast <kwm@rainbow-runner.nl> Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>