mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
read-only mirror of https://gitlab.freedesktop.org/mesa/mesa
This patch fixes memory leaks when reply is allocated and is not freed
on error execution path.
Found by enabling address sanitizer on simple EGL app.
```c
int main()
{
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
EGLint major;
EGLint minor;
if (!eglInitialize(display, &major, &minor))
{
return 1;
}
eglTerminate(display);
return 0;
}
```
Compiled with: `gcc testme.c -o testme -fsanitize=address -lasan -lEGL`
Execution environment:
- Windows 10, VMWare Player 15.5.2 build-15785246 without 3D accelaration
- Guest OS: OpenSUSE Leap 15.2
- Mesa 19.3.4
Program output:
```sh
ASAN_OPTIONS=fast_unwind_on_malloc=0 ./testme
libEGL warning: DRI2: failed to authenticate
==52510==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 32 byte(s) in 1 object(s) allocated from:
#0 0x7fa62315f500 in malloc (/usr/lib64/libasan.so.4+0xdc500)
#1 0x7fa61e12d86b (/usr/lib64/libxcb.so.1+0xf86b)
#2 0x7fa61e12b5c7 (/usr/lib64/libxcb.so.1+0xd5c7)
#3 0x7fa61e12cc3e (/usr/lib64/libxcb.so.1+0xec3e)
#4 0x7fa61e12cd4f in xcb_wait_for_reply (/usr/lib64/libxcb.so.1+0xed4f)
#5 0x7fa61ebe02a5 (/usr/lib64/libEGL_mesa.so.0+0x202a5)
#6 0x7fa61ebdb5ca (/usr/lib64/libEGL_mesa.so.0+0x1b5ca)
#7 0x7fa61ebd750c (/usr/lib64/libEGL_mesa.so.0+0x1750c)
#8 0x7fa61ebd7554 (/usr/lib64/libEGL_mesa.so.0+0x17554)
#9 0x7fa61ebd1107 (/usr/lib64/libEGL_mesa.so.0+0x11107)
#10 0x400856 in main (/home/user/testme+0x400856)
#11 0x7fa622ad8349 in __libc_start_main (/lib64/libc.so.6+0x24349)
#12 0x4006e9 in _start (/home/user/testme+0x4006e9)
SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).
```
Signed-off-by: Andrey Vostrikov <av.linux.dev@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6611>
(cherry picked from commit
|
||
|---|---|---|
| .appveyor | ||
| .gitlab/issue_templates | ||
| .gitlab-ci | ||
| bin | ||
| build-support | ||
| docs | ||
| doxygen | ||
| include | ||
| scons | ||
| src | ||
| subprojects | ||
| .dir-locals.el | ||
| .editorconfig | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .mailmap | ||
| .pick_status.json | ||
| .travis.yml | ||
| Android.common.mk | ||
| Android.mk | ||
| appveyor.yml | ||
| CleanSpec.mk | ||
| common.py | ||
| meson.build | ||
| meson_options.txt | ||
| README.rst | ||
| REVIEWERS | ||
| SConstruct | ||
| VERSION | ||
`Mesa <https://mesa3d.org>`_ - The 3D Graphics Library ====================================================== Source ------ This repository lives at https://gitlab.freedesktop.org/mesa/mesa. Other repositories are likely forks, and code found there is not supported. Build & install --------------- You can find more information in our documentation (`docs/install.rst <https://mesa3d.org/install.html>`_), but the recommended way is to use Meson (`docs/meson.rst <https://mesa3d.org/meson.html>`_): .. code-block:: sh $ mkdir build $ cd build $ meson .. $ sudo ninja install Support ------- Many Mesa devs hang on IRC; if you're not sure which channel is appropriate, you should ask your question on `Freenode's #dri-devel <irc://chat.freenode.net#dri-devel>`_, someone will redirect you if necessary. Remember that not everyone is in the same timezone as you, so it might take a while before someone qualified sees your question. To figure out who you're talking to, or which nick to ping for your question, check out `Who's Who on IRC <https://dri.freedesktop.org/wiki/WhosWho/>`_. The next best option is to ask your question in an email to the mailing lists: `mesa-dev\@lists.freedesktop.org <https://lists.freedesktop.org/mailman/listinfo/mesa-dev>`_ Bug reports ----------- If you think something isn't working properly, please file a bug report (`docs/bugs.rst <https://mesa3d.org/bugs.html>`_). Contributing ------------ Contributions are welcome, and step-by-step instructions can be found in our documentation (`docs/submittingpatches.rst <https://mesa3d.org/submittingpatches.html>`_). Note that Mesa uses gitlab for patches submission, review and discussions.