After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 767383 - Critical error gst_buffer_map_range: assertion 'GST_IS_BUFFER (buffer)' failed with gst-validate
Critical error gst_buffer_map_range: assertion 'GST_IS_BUFFER (buffer)' faile...
Status: RESOLVED NOTABUG
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
1.6.3
Other Linux
: Normal critical
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-06-08 10:13 UTC by yvonne.chen
Modified: 2016-06-14 01:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
stream file to reproduce (347.46 KB, video/webm)
2016-06-12 02:54 UTC, yvonne.chen
Details
valgrind log (113.55 KB, text/plain)
2016-06-13 08:57 UTC, yvonne.chen
Details

Description yvonne.chen 2016-06-08 10:13:43 UTC
Hello,
   need your help , gstreamer-1.6.3 with gst-validate-1.6.0 I caught
Critical error gst_buffer_map_range: assertion 'GST_IS_BUFFER (buffer)' failed when running gst-validate-media-check-1.0 . need you  guys'help to fix it, thanks
(gdb) bt
  • #0 gst_buffer_map_range
    at gstbuffer.c line 1630
  • #1 gst_buffer_map
  • #2 gst_value_serialize_buffer
    at gstvalue.c line 2291
  • #3 gst_value_serialize
    at gstvalue.c line 5283
  • #4 gst_value_serialize_any_list
    at gstvalue.c line 200
  • #5 gst_value_serialize
    at gstvalue.c line 5283
  • #6 priv_gst_structure_append_to_gstring
    at gststructure.c line 1919
  • #7 gst_caps_to_string
    at gstcaps.c line 2213
  • #8 ??
    from /mnt/nfsroot/yvonne.chen/Linux/buildroot/output/target/usr/lib/arm-linux-gnueabihf/libgstvalidate-1.0.so.0

Comment 1 Sebastian Dröge (slomo) 2016-06-08 10:18:53 UTC
Can you check if this is still a problem with 1.8.1?

Which test are you running, and on which file? Can you share the file? Does it always happen?
Comment 2 yvonne.chen 2016-06-12 02:54:09 UTC
Following is the test  and the stream file attached.
gst-validate-launcher -M /mnt/gst-validate --generate-media-info -t  validate.file.media_check.vorbis_vp8_1_webm

[1 / 1] Launching: validate.file.media_check.vorbis_vp8_1_webm
    Command: 'GST_GL_XINITTHREADS=1 DISPLAY=:0 gst-validate-media-check-1.0  file:///mnt/gst-validate/gst-integration-testsuites/medias/defaults/webm/vorbis_vp8.1.webm --expected-results "/mnt/gst-validate/gst-integration-testsuites/medias/defaults/webm/vorbis_vp8.1.webm.media_info"'
    Logs:
         - /mnt/gst-validate/logs/validate/file/media_check/vorbis_vp8_1_webm
         - /mnt/gst-validate/logs/validate/file/media_check/vorbis_vp8_1_webm.validate.logs
[1 / 1] validate.file.media_check.vorbis_vp8_1_webm: Failed (Application returned 1 (issues: No criticals))

 
I am runnig an  embedded  system. we use different video sink plugin and audio decoder and sink plugin we write. I am not sure this is caused by the plugin we write. I still hope you guy can reproduce it and help to fix.

If not ,could any one tell me how to quickly and accurately locate and fix the problem?
Comment 3 yvonne.chen 2016-06-12 02:54:42 UTC
Created attachment 329629 [details]
stream file to reproduce
Comment 4 Sebastian Dröge (slomo) 2016-06-13 07:00:34 UTC
I would expect this to be related to your platform or the other elements you are using. It seems to work fine here with 1.8.2 and GIT master. please in the future also file only a single bug, it seems to be all the same problem.


For locating this, somewhere in the code the reference counting is apparently done wrong. Most likely related to a GstBuffer that is stored in caps, or it's just memory corruption elsewhere. Best would be to run in valgrind with --track-origins=yes to see what goes wrong and where the memory is from.
Comment 5 yvonne.chen 2016-06-13 08:57:01 UTC
Created attachment 329669 [details]
valgrind log
Comment 6 Sebastian Dröge (slomo) 2016-06-13 09:05:26 UTC
Seems to be related to buffers/memory stored inside the caps, the streamheaders. Please check if your custom elements downstream of the demuxer are handling reference counts of buffers and also the streamheaders inside the caps correctly. As this doesn't happen here, it's probably related to what your custom elements are doing.
Comment 7 yvonne.chen 2016-06-13 09:06:56 UTC
from the log , I still can not locate the problem. I also expect this  to be related to my plugin, but I see nothing related to my plugin from the log. Following may be the related codes. Could you help me to check it? especially the buffer related? 
====================part 1============== 
if (gst_structure_has_field(structure, "streamheader")) {
		 headers = gst_structure_get_value (structure, "streamheader");
        if (headers == NULL || !GST_VALUE_HOLDS_ARRAY (headers)) {
            GST_WARNING ( "no 'streamheader' field in input caps,\n");
            return FALSE;
        }
        num = gst_value_array_get_size (headers);
        GST_WARNING ( "num=%d\n",num);	
        for (i = 0; i < num; ++i) {
            const GValue *header_val;
            GstBuffer *header_buf;

            header_val = gst_value_array_get_value (headers, i);
            if (header_val == NULL || !GST_VALUE_HOLDS_BUFFER (header_val))
            return FALSE;
	   if(i==0){
	      info->configdata =                    gst_buffer_make_writable(gst_value_get_buffer(header_val));
		          if(pcodec->audio_type == AFORMAT_VORBIS)
		   	      pcodec->audio_info.extradata[1] = gst_buffer_get_size (info->configdata );
	          } else {
	   	       header_buf = g_value_dup_boxed (header_val);
		         if(pcodec->audio_type ==AFORMAT_VORBIS && i==1)
		   	     pcodec->audio_info.extradata[2] = gst_buffer_get_size (header_buf);
                GST_WARNING ("pushing header buffer of %" G_GSIZE_FORMAT " bytes "
              " into adapter", gst_buffer_get_size (header_buf));
		         if(header_buf)
	             gst_buffer_copy_into(info->configdata,header_buf,GST_BUFFER_COPY_MEMORY,0,-1);	     
		       }
	      } 
    }


=================part2========================================
gint vorbis_writeheader(AmlStreamInfo* info, codec_para_t *pcodec)
{
	GstMapInfo map;
    if(info->configdata){
    	gst_buffer_map(info->configdata, &map, GST_MAP_READ);
        pcodec->audio_info.extradata_size = map.size;
	   GST_WARNING("size=%d\n",pcodec->audio_info.extradata_size);
        if (pcodec->audio_info.extradata_size > 0) {
            if (pcodec->audio_info.extradata_size >  AUDIO_EXTRA_DATA_SIZE) {
                GST_WARNING("[%s:%d],extra data size exceed max  extra data buffer,cut it to max buffer size ", __FUNCTION__, __LINE__);
                pcodec->audio_info.extradata_size =  AUDIO_EXTRA_DATA_SIZE;
            }
		 pcodec->audio_info.extradata[0] = 0x02;
            memcpy((char*)pcodec->audio_info.extradata+3, map.data, pcodec->audio_info.extradata_size);
        }
        gst_buffer_unmap(info->configdata, &map);
    }
	pcodec->audio_info.extradata_size= pcodec->audio_info.extradata_size +3;
    pcodec->audio_info.valid = 1;
    return 0;	
}
gint vorbis_startcode(AmlStreamInfo* info, codec_para_t *pcodec, GstBuffer *buffer)
{
	gint32 buf_size;
    char head[] = "HEAD";

    codec_write(pcodec, head, 4);
    buf_size = gst_buffer_get_size(buffer);
    codec_write(pcodec, &buf_size, 4);

    return 0;

}
Comment 8 yvonne.chen 2016-06-13 09:12:22 UTC
sorry for the type setting, Could you help to review the codes above? I know little about reference counts of buffers and buffer operation .Could you give me more info indetail?
Comment 9 Sebastian Dröge (slomo) 2016-06-13 09:15:19 UTC
There's not enough context to say anything about this code. One possible problem is this though:

> info->configdata =                    
>     gst_buffer_make_writable(gst_value_get_buffer(header_val));

With this you invalidate the buffer that is inside the array inside the caps, and as such later usage of the caps causes problems. Copy the buffer here instead of example.

Also below you do g_value_dup_boxed() (which is ok), but you forget to unref the buffer. So would leak it.
Comment 10 yvonne.chen 2016-06-13 09:24:42 UTC
Thanks I will try what you said.
Here is the context.
for vorbis, streamheader consists value arry with num=3;
I have to get the three buffers data from the three value arry and then copy to one buffer called info->configdata; The initial there bytes of info->configdata must be 0x02 、 the second buffer size、the third buffer size to initialize  my decoder.
Comment 11 Sebastian Dröge (slomo) 2016-06-13 09:28:43 UTC
I know what that code is doing, but not what else is around it :) That's what I meant with context. I can only guess
Comment 12 yvonne.chen 2016-06-13 10:14:14 UTC
Thanks, it works!
Comment 13 Sebastian Dröge (slomo) 2016-06-13 10:24:49 UTC
Also your two other bugs?
Comment 14 yvonne.chen 2016-06-14 01:40:04 UTC
Yes closed thanks