Skip to content

buffer_copy: Assertion `dest' failed when parsing UMN mapfile #58

Closed

Description

@pka

Calling

/usr/lib/cgi-bin/tinyows -check

with TINYOWS_MAPFILE set gives the following exit error message:

tinyows: src/struct/buffer.c:348: buffer_copy: Assertion `dest' failed.

It happens with any map file including the example from http://mapserver.org/tinyows/mapfileconfig.html

Version 1.1.0 on Ubuntu 12.04 from UbuntuGIS and master branch compiled on the same machine.

Backtrace:

#0  0x00007ffff72bb425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff72beb8b in __GI_abort () at abort.c:91
#2  0x00007ffff72b40ee in __assert_fail_base (fmt=<optimized out>, assertion=0x42a1ab "dest", 
file=0x42a16d "src/struct/buffer.c", line=<optimized out>, function=<optimized out>) at assert.c:94
#3  0x00007ffff72b4192 in __GI___assert_fail (assertion=0x42a1ab "dest", file=0x42a16d "src/struct/buffer.c", line=348, 
function=0x42a400 "buffer_copy") at assert.c:103
#4  0x0000000000415d34 in buffer_copy (dest=<optimized out>, src=<optimized out>) at src/struct/buffer.c:348
#5  buffer_copy (dest=<optimized out>, src=<optimized out>) at src/struct/buffer.c:346
#6  0x000000000040a951 in end_layer () at src/mapfile/mapfile.l:542
#7  yylex () at src/mapfile/mapfile.l:614
#8  0x000000000040b6d5 in ows_parse_config_mapfile (o=0x634040, filename=<optimized out>) at src/mapfile/mapfile.l:789
#9  0x000000000040c848 in ows_parse_config (o=0x634040, filename=<optimized out>) at src/ows/ows_config.c:706
#10 0x0000000000402ba1 in main (argc=2, argv=0x7fffffffde78) at src/ows/ows.c:360

The following changes fix the crash:

diff --git a/src/mapfile/mapfile.l b/src/mapfile/mapfile.l
index 36066e9..474a4d7 100644
--- a/src/mapfile/mapfile.l
+++ b/src/mapfile/mapfile.l
@@ -539,12 +539,14 @@ static void end_layer()
            buffer_add_str(map_l->storage->schema, "public");
        if (!map_is_dump) map_l->retrievable=map_l->writable = false;

+                map_l->name_prefix = buffer_init();
        buffer_copy(map_l->name_prefix, map_l->name);
        if (map_l->ns_prefix->use) {
        buffer_add_head(map_l->name_prefix, ':');
        buffer_add_head_str(map_l->name_prefix, map_l->ns_prefix->buf);
        }

+                map_l->name_no_uri = buffer_init();
        buffer_copy(map_l->name_no_uri, map_l->name);
        if (map_l->ns_uri->use) {

Activity

  1. jlarouche commented on Mar 28, 2013

    @jlarouche

    Thank you for the fix, but it should be in mapfile.c instead of mapfile.l

    The issue has been patched in UbuntuGIS thanks to you fix.

    EDIT: @pka is right, removed my patch

  2. pka commented on Mar 28, 2013

    @pka
    Author

    Hi Jérôme,
    mapfile.c is generated from mapfile.l with flex. The step has to be done manually, because it's missing in the Makefile.
    Pirmin

  3. jlarouche commented on Mar 28, 2013

    @jlarouche

    Ah, sorry about that, it makes more sense now thank you.

  4. added a commit that references this issue on Sep 25, 2014
  5. stetou commented on Jan 27, 2015

    @stetou

    Is this supposed to be fixed now? I do have this problem
    tinyows: src/struct/buffer.c:348: buffer_copy: Assertion `dest' failed. when running tunyows -check using a mapfile.

    The code above is different of what I have in mapfile.l

  6. added this to the 1.2.1 milestone on Jun 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions