Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 857
    • Issues 857
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 45
    • Merge requests 45
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • GLib
  • Issues
  • #1342
Closed
Open
Issue created Feb 12, 2018 by Bugzilla@bugzilla-migration💬Reporter

Automatically realign data passed to g_variant_new_from_bytes() or g_variant_new_from_data()

Submitted by Philip Withnall @pwithnall

Link to original bug (#793394)

Description

If a byte array which is passed to g_variant_new_from_bytes|data is not sufficiently aligned for the given GVariantType, a critical warning will be emitted:

gvariant-serialiser.c:167:g_variant_serialised_check: assertion failed (alignment & (gsize) serialised.data == 0): (4 == 0)

The caller can’t know what alignment the GVariantType is meant to have (it’s not exposed in public API) — and even if they were, making every caller of g_variant_new_from_bytes|data realign their data amounts to a lot of code.

It would be better if the realignment was done (only if needed) in gvariant-core.c, and documented. If callers care about speed, they can ensure their byte arrays are correctly aligned before passing them to GVariant.

This also means we can eliminate the align_malloc() faff in glib/tests/gvariant.c, and partially revert commit 7b607082.

Version: 2.55.x

Assignee
Assign to
Time tracking