Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add a test for a crash in bigreqs.
The failing struct comes from the python test written by Michal Srb <msrb@suse.com>. However, that test the crash by setting the server to big-endian mode so we tried to swap a bunch of polylines data. Any clever ideas for something better? Signed-off-by: Eric Anholt <eric@anholt.net>
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
xcb_dep = dependency('xcb', required: false) | ||
xcb_sync_dep = dependency('xcb-sync', required: false) | ||
|
||
if get_option('xvfb') | ||
if xcb_dep.found() | ||
requestlength = executable('request-length', 'request-length.c', dependencies: xcb_dep) | ||
test('request-length', simple_xinit, args: [requestlength, '--', xvfb_server]) | ||
endif | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright © 2017 Broadcom | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice (including the next | ||
* paragraph) shall be included in all copies or substantial portions of the | ||
* Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <poll.h> | ||
#include <xcb/xcb.h> | ||
#include <xcb/bigreq.h> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int screen; | ||
xcb_connection_t *c = xcb_connect(NULL, &screen); | ||
int fd = xcb_get_file_descriptor(c); | ||
struct { | ||
uint8_t reqtype; | ||
uint8_t coordmode; | ||
uint16_t length; | ||
uint32_t length_bigreq; | ||
uint32_t drawable; | ||
uint32_t gc; | ||
} polyline_req = { | ||
.reqtype = XCB_POLY_LINE, | ||
|
||
/* This is the value that triggers the bug. */ | ||
.length_bigreq = 0, | ||
}; | ||
|
||
free(xcb_big_requests_enable_reply(c, xcb_big_requests_enable(c), NULL)); | ||
|
||
/* Manually write out the bad request. XCB can't help us here.*/ | ||
write(fd, &polyline_req, sizeof(polyline_req)); | ||
|
||
/* Block until the server has processed our mess. If the server | ||
* crashes, the simple-xinit will return failure. | ||
*/ | ||
struct pollfd pfd = { | ||
.fd = fd, | ||
.events = POLLIN, | ||
}; | ||
poll(&pfd, 1, -1); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ if get_option('xvfb') | |
endif | ||
endif | ||
|
||
subdir('bigreq') | ||
subdir('sync') |