LADI attempts for https://gitlab.gnome.org/GNOME/cogl revival
Go to file
Simon McVittie 76592f6415 test-premult: Don't free texture data until CoglBitmap is freed
According to the cogl_bitmap_new_for_data documentation, the data is not
copied, so the application must keep the buffer alive for the lifetime
of the CoglBitmap. Freeing it too early led to a use-after-free in the
cogl unit tests.

==6223==ERROR: AddressSanitizer: heap-use-after-free on address 0x62100001a500 at pc 0x7f3e2d4e7f4e bp 0x7ffcd9c41f30 sp 0x7ffcd9c416e0
READ of size 4096 at 0x62100001a500 thread T0
    #0 0x7f3e2d4e7f4d  (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x96f4d)
    #1 0x7f3e260c7f6b in util_copy_box ../src/gallium/auxiliary/util/u_surface.c:131
    #2 0x7f3e268c6c10 in u_default_texture_subdata ../src/gallium/auxiliary/util/u_transfer.c:67
    #3 0x7f3e26486459 in st_TexSubImage ../src/mesa/state_tracker/st_cb_texture.c:1480
    #4 0x7f3e26487029 in st_TexImage ../src/mesa/state_tracker/st_cb_texture.c:1709
    #5 0x7f3e26487029 in st_TexImage ../src/mesa/state_tracker/st_cb_texture.c:1691
    #6 0x7f3e2644bdba in teximage ../src/mesa/main/teximage.c:3105
    #7 0x7f3e2644bdba in teximage_err ../src/mesa/main/teximage.c:3132
    #8 0x7f3e2644d84f in _mesa_TexImage2D ../src/mesa/main/teximage.c:3170
    #9 0x7f3e2cd1f7df in _cogl_texture_driver_upload_to_gl driver/gl/gl/cogl-texture-driver-gl.c:347
    #10 0x7f3e2ccd441b in allocate_from_bitmap driver/gl/cogl-texture-2d-gl.c:255
    #11 0x7f3e2ccd441b in _cogl_texture_2d_gl_allocate driver/gl/cogl-texture-2d-gl.c:462
    #12 0x7f3e2ce3a6c0 in cogl_texture_allocate cogl/cogl-texture.c:1398
    #13 0x7f3e2ce3e116 in _cogl_texture_pre_paint cogl/cogl-texture.c:359
    #14 0x7f3e2cdee177 in _cogl_pipeline_layer_pre_paint cogl/cogl-pipeline-layer.c:864
    #15 0x7f3e2cd574af in _cogl_rectangles_validate_layer_cb cogl/cogl-primitives.c:542
    #16 0x7f3e2cdd742f in cogl_pipeline_foreach_layer cogl/cogl-pipeline.c:735
    #17 0x7f3e2cd5c8b0 in _cogl_framebuffer_draw_multitextured_rectangles cogl/cogl-primitives.c:658
    #18 0x7f3e2cd60152 in cogl_rectangle cogl/cogl-primitives.c:858
    #19 0x5570a71ed6a0 in check_texture tests/conform/test-premult.c:103
    #20 0x5570a71ed946 in test_premult tests/conform/test-premult.c:159
    #21 0x5570a71df0d6 in main tests/conform/test-conform-main.c:58
    #22 0x7f3e2bcd809a in __libc_start_main ../csu/libc-start.c:308
    #23 0x5570a71e0869 in _start (/home/smcv/src/debian/cogl/tests/conform/.libs/test-conformance+0x33869)

0x62100001a500 is located 0 bytes inside of 4096-byte region [0x62100001a500,0x62100001b500)
freed by thread T0 here:
    #0 0x7f3e2d5581d7 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x1071d7)
    #1 0x5570a71ed58b in make_texture tests/conform/test-premult.c:69

previously allocated by thread T0 here:
    #0 0x7f3e2d558588 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x107588)
    #1 0x7f3e2d384500 in g_malloc ../../../glib/gmem.c:99

Signed-off-by: Simon McVittie <smcv@debian.org>
2019-09-06 08:58:15 +01:00
build mingw: Try adding a -w64 suffix when searching for a suitable compiler 2014-03-21 17:29:40 +00:00
cogl Use Unicode in translatable strings 2019-02-22 17:43:16 +01:00
cogl-gles2 build: update to build with automake 1.13 2013-01-21 17:24:33 +00:00
cogl-gst cogl-gst-plugin: Fix the license name in the plugin description 2014-03-14 17:11:43 +00:00
cogl-pango cogl-pango-pipeline-cache.c: Include forgotten header 2014-03-20 18:05:12 +00:00
cogl-path This re-licenses Cogl under the MIT license 2014-01-14 22:55:12 +00:00
deps Updated FSF's address 2014-01-31 14:33:23 +01:00
doc Tweak documentation for the CoglTexture interface 2014-01-20 14:23:38 +00:00
examples examples/cogl-texture-pixmap-x11: Add a --stereo command line option 2014-07-17 19:13:50 -04:00
po Add Finnish translation 2019-08-22 16:46:59 +00:00
test-fixtures Add support for RG textures 2014-01-20 14:28:43 +00:00
tests test-premult: Don't free texture data until CoglBitmap is freed 2019-09-06 08:58:15 +01:00
.gitignore Update .gitignore 2013-11-29 14:02:48 +00:00
.vimrc misc: Add a .vimrc file 2011-05-17 15:24:54 +01:00
COPYING This re-licenses Cogl under the MIT license 2014-01-14 22:55:12 +00:00
ChangeLog dist: Don't use elaborate script to gen Changelogs 2011-07-20 16:58:46 +01:00
Makefile.am Separate out CoglPath api into sub-library 2013-06-12 11:55:26 +01:00
NEWS Updates NEWS for the 1.10.0 release 2012-03-20 17:13:16 +00:00
README.in This re-licenses Cogl under the MIT license 2014-01-14 22:55:12 +00:00
autogen.sh Upgrade to gettext 0.19 to avoid hack in autogen.sh 2016-01-08 12:08:41 +00:00
cogl.doap Update DOAP file 2018-06-18 10:06:56 +01:00
config-custom.h This re-licenses Cogl under the MIT license 2014-01-14 22:55:12 +00:00
config.h.win32.in Update config.h.win32.in 2013-03-15 00:29:56 +08:00
configure.ac Upgrade to gettext 0.19 to avoid hack in autogen.sh 2016-01-08 12:08:41 +00:00

README.in

README for Cogl @COGL_1_VERSION@
===============================================================================

Note: This file is delimited with -- markers so it is possible to split
sections out for other purposes, such as for release notes.

--
DESCRIPTION
-------------------------------------------------------------------------------

Cogl is a small open source library for using 3D graphics hardware for
rendering. The API departs from the flat state machine style of OpenGL and is
designed to make it easy to write orthogonal components that can render without
stepping on each others toes.

As well as aiming for a nice API, we think having a single library as opposed
to an API specification like OpenGL has a few advantages too; like being
able to paper over the inconsistencies/bugs of different OpenGL
implementations in a centralized place, not to mention the myriad of OpenGL
extensions. It also means we are in a better position to provide utility
APIs that help software developers since they only need to be implemented
once and there is no risk of inconsistency between implementations.

Having other backends, besides OpenGL, such as drm, Gallium or D3D are
options we are interested in for the future.

--
REQUIREMENTS
-------------------------------------------------------------------------------

Cogl currently only requires:

  • OpenGL ≥ 1.3 (or 1.2 + multitexturing), or OpenGL ES 2.0 (or 1.1)
  • GLX, AGL, WGL or an EGL implementation

Cogl also has optional dependencies:

  • GLib ≥ @GLIB_REQ_VERSION@
     - for gtype integration
  • GDK-Pixbuf ≥ @GDK_PIXBUF_REQ_VERSION@
     - for image loading
  • Cairo ≥ @CAIRO_REQ_VERSION@
     - for debugging texture atlasing (debug builds only)

The optional Cogl Pango library requires:
  • Cairo ≥ @CAIRO_REQ_VERSION@
  • PangoCairo ≥ @PANGOCAIRO_REQ_VERSION@

The optional Cogl GStreamer library requires:

  • GStreamer 1.0

On X11, Cogl depends on the following extensions

  • XComposite ≥ @XCOMPOSITE_REQ_VERSION@
  • XDamage
  • XExt
  • XFixes ≥ @XFIXES_REQ_VERSION@

For the Wayland backend, Cogl requires:
  • Wayland ≥ @WAYLAND_REQ_VERSION@

When running with OpenGL, Cogl requires at least version 1.3
or 1.2 with the multitexturing extension. However to build Cogl
you will need the latest GL headers which can be obtained from:

  http://www.khronos.org

If you are building the API reference you will also need:

  • GTK-Doc ≥ @GTK_DOC_REQ_VERSION@

If you are building the additional documentation you will also need:

  • xsltproc
  • jw (optional, for generating PDFs)

If you are building the Introspection data you will also need:

  • GObject-Introspection ≥ @GI_REQ_VERSION@

GObject-Introspection is available from:

  git://git.gnome.org/gobject-introspection

If you want support for profiling Cogl you will also need:

  • UProf ≥ @UPROF_REQ_VERSION@

UProf is available from:

  git://github.com/rib/UProf.git

--
DOCUMENTATION
-------------------------------------------------------------------------------

The 1.x stable API is documented here:

   http://developer.gnome.org/cogl/stable/

The 1.x development API is documented here:

  http://developer.gnome.org/cogl/1.@COGL_1_MINOR_VERSION@

The experimental 2.0 API is documented here:

  http://cogl3d.org/cogl2-reference/

--
LICENSE
-------------------------------------------------------------------------------

Most of Cogl is licensed under the terms of the MIT license. There are
also some files under the SGI Free Software License B, version 2.0,
cogl-point-in-poly.c is under a 3 clause BSD license and stb_image.c
is public domain. Please see individual files for details.

deps/glib is licensed under the LGPL (please see individual files for
details and deps/glib/COPYING for a copy of the LGPL license) This
code is only referenced when building Cogl with the --standalone
configure option.

--
BUILDING AND INSTALLATION
-------------------------------------------------------------------------------

Please refer to the INSTALL document.

--
BUGS
-------------------------------------------------------------------------------

Please report bugs here:

  http://bugzilla.gnome.org/enter_bug.cgi?product=cogl

You will need a Bugzilla account.

Please include the following in bug reports:

  • what system you're running Cogl on;
  • which version of Cogl you are using;
  • which version of GLib and OpenGL (or OpenGL ES) you are using;
  • which video card and which drivers you are using, including output of
    glxinfo and xdpyinfo (if applicable);
  • how to reproduce the bug.

If you cannot reproduce the bug with one of the tests that come with
Cogl's source code, it can help a lot to include a small test case
displaying the bad behaviour.

If the bug exposes a crash, the exact text printed out and a stack trace
obtained using gdb are greatly appreciated.

--
CONTRIBUTING
-------------------------------------------------------------------------------

The CODING_STYLE file describes the coding style we use throughout Cogl,
please try your best to conform to this style because the consistency
really helps keep the code maintainable.

We can accept contributions in several ways:
  • Either as patches attached to bugs on bugzilla
      - For this you may be interested in using git-bz.

        See http://git.fishsoup.net/man/git-bz.html for details
  • You can email us patches
      - For this we recommend using git-send-email

  • You can create a remote branch and ask us to pull from that for more
    substantial changes.
      - For this we recommend using github.

Ideally standalone patches should be created using git format-patch since
that makes it easiest to import the patch with a commit message into a
git repository.