jkuri / opencv-ffmpeg-rtmp-stream

OpenCV FFMpeg Live Video Stream over RTMP protocol.
MIT License
210 stars 59 forks source link

received signal SIGBUS, Bus error. #4

Open berli opened 6 years ago

berli commented 6 years ago

OS: Ubuntu 16.04 I got the received signal SIGBUS, Bus error when running; I gdb it and get the following information

`Thread 1 "rtmp-stream" hit Breakpoint 1, stream_video (width=800, height=600, fps=30, camID="0", bitrate=300000, codec_profile="high444", server="rtmp://localhost/live/stream") at /home/berli/Test/camera-opencv-ffmpeg-rtmp-stream/src/rtmp-stream.cpp:212

212 sws_scale(swsctx, &image.data, stride, 0, image.rows, frame->data, frame->linesize); (gdb) n 213 frame->pts += av_rescale_q(1, out_codec_ctx->time_base, out_stream->time_base);

(gdb) p *frame

$14 = {data = { 0xdfc220 "\\\\]]]\]]^^a_ab`aaaabbbbbbbeegeefggfeeeggghhhhghgfghijjjlkkjjkkkkjlkjjkllkkllllnnnnnlnnnnoonnoonmnnnnmnmmnnnnoooqooonlnnpoopoonopoppopoopppppqqnnnnoqoopopoppoooooonnqqqqonpoononooppppqqrqppppppooop"..., 0xe71520 "wwwwxxwutuvvvvttuxwxvttuuuuwzywtssssuwwxxvuuutstwyzyvttuxyxvvvvvwwwwxxwwxwvwwxxvttuvwwvvvvvvxyyxxwwuvvwuvvxwxz{zustvwwxxxxwvvvvtuvwyyzzzyxvvvwwvttwzzxtquxxuuuuvwwuvwwwtrsvyzyxvssttvvxuutwy{{yyyyyxwvvx"..., 0xe8e9e0 "vvtvvvsqppnpqqqpquutrpssqsutttttrrrqoprtusqpqrqqqrstusqqsqqruwvuvvtrqqrrrqqqqqooqtvvttsrqsttvuuvtttvtsrsuwvvwvttssuutrrttvvwuuwuvwwwutuwwwuuuvyxvvwvuuuuttusttssrrsvwxwwusuwzyxuuutttvusttuuvvuwwwwxxwuu"..., 0x0, 0x0, 0x0, 0x0, 0x0}, linesize = {800, 400, 400, 0, 0, 0, 0, 0}, extended_data = 0x81c000, width = 800, height = 600, nb_samples = 0, format = 0, key_frame = 1, pict_type = AV_PICTURE_TYPE_NONE, sample_aspect_ratio = {num = 0, den = 1}, pts = -9223372036854775808, pkt_pts = -9223372036854775808, pkt_dts = -9223372036854775808, coded_picture_number = 0, display_picture_number = 0, quality = 0, opaque = 0x0, error = {0, 0, 0, 0, 0, 0, 0, 0}, repeat_pict = 0, interlaced_frame = 0, top_field_first = 0, palette_has_changed = 0, reordered_opaque = 0, sample_rate = 0, channel_layout = 0, buf = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, extended_buf = 0x0, nb_extended_buf = 0, side_data = 0x0, nb_side_data = 0, flags = 0, color_range = AVCOL_RANGE_UNSPECIFIED, color_primaries = AVCOL_PRI_UNSPECIFIED, color_trc = AVCOL_TRC_UNSPECIFIED, colorspace = AVCOL_SPC_UNSPECIFIED, chroma_location = AVCHROMA_LOC_UNSPECIFIED, best_effort_timestamp = -9223372036854775808, pkt_pos = -1, pkt_duration = 0, metadata = 0x0, decode_error_flags = 0, channels = 0, pkt_size = -1, qscale_table = 0x0, qstride = 0, qscale_type = 0, qp_table_buf = 0x0, hw_frames_ctx = 0x0, opaque_ref = 0x0, crop_top = 0, crop_bottom = 0, crop_left = 0, crop_right = 0, private_ref = 0x0} (gdb) p swsctx $15 = (gdb) p swsctx $16 = (SwsContext ) 0xde4700 (gdb) p *swsctx No symbol "operator" in current context. (gdb) n 214 write_frame(out_codec_ctx, ofmt_ctx, frame); (gdb) p out_codec_ctx $17 = {av_class = 0x7ffff75bfee0, log_level_offset = 0, codec_type = AVMEDIA_TYPE_VIDEO, codec = 0x7ffff75ec460, codec_id = AV_CODEC_ID_H264, codec_tag = 0, priv_data = 0x669640, internal = 0x667380, opaque = 0x0, bit_rate = 300000, bit_rate_tolerance = 4000000, global_quality = 0, compression_level = -1, flags = -2143289344, flags2 = 0, extradata = 0x81bc80 "", extradata_size = 37, time_base = { num = 1, den = 30}, ticks_per_frame = 1, delay = 0, width = 800, height = 600, coded_width = 800, coded_height = 600, gop_size = 12, pix_fmt = AV_PIX_FMT_YUV420P, draw_horiz_band = 0x0, get_format = 0x7ffff696bb80 , max_b_frames = 0, b_quant_factor = -1, b_frame_strategy = -1, b_quant_offset = 1.25, has_b_frames = 0, mpeg_quant = 0, i_quant_factor = -1, i_quant_offset = 0, lumi_masking = 0, temporal_cplx_masking = 0, spatial_cplx_masking = 0, p_masking = 0, dark_masking = 0, slice_count = 0, prediction_method = 0, slice_offset = 0x0, sample_aspect_ratio = {num = 0, den = 1}, me_cmp = -1, me_sub_cmp = 0, mb_cmp = 0, ildct_cmp = 8, dia_size = 0, last_predictor_count = 0, pre_me = 0, me_pre_cmp = 0, pre_dia_size = 0, me_subpel_quality = -1, me_range = -1, slice_flags = 0, mb_decision = 0, intra_matrix = 0x0, inter_matrix = 0x0, scenechange_threshold = -1, noise_reduction = -1, intra_dc_precision = 0, skip_top = 0, skip_bottom = 0, mb_lmin = 236, mb_lmax = 3658, me_penalty_compensation = 256, bidir_refine = 1, brd_scale = 0, keyint_min = -1, refs = -1, chromaoffset = 0, mv0_threshold = 256, b_sensitivity = 40, color_primaries = AVCOL_PRI_UNSPECIFIED, color_trc = AVCOL_TRC_UNSPECIFIED, colorspace = AVCOL_SPC_UNSPECIFIED, color_range = AVCOL_RANGE_UNSPECIFIED, chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED, slices = 0, field_order = AV_FIELD_UNKNOWN, sample_rate = 0, channels = 0, sample_fmt = AV_SAMPLE_FMT_NONE, frame_size = 0, frame_number = 0, block_align = 0, cutoff = 0, channel_layout = 0, request_channel_layout = 0, audio_service_type = AV_AUDIO_SERVICE_TYPE_MAIN, request_sample_fmt = AV_SAMPLE_FMT_U8, get_buffer2 = 0x7ffff696c380 , refcounted_frames = 0, qcompress = -1, qblur = -1, qmin = -1, qmax = -1, max_qdiff = -1, rc_buffer_size = 0, rc_override_count = 0, rc_override = 0x0, rc_max_rate = 0, rc_min_rate = 0, rc_max_available_vbv_use = 0, rc_min_vbv_overflow_use = 3, rc_initial_buffer_occupancy = -1, coder_type = -1, context_model = 0, frame_skip_threshold = 0, frame_skip_factor = 0, frame_skip_exp = 0, frame_skip_cmp = 13, trellis = -1, min_prediction_order = 0, max_prediction_order = 0, timecode_frame_start = -1, rtp_callback = 0x0, rtp_payload_size = 0, mv_bits = 0, header_bits = 0, i_tex_bits = 0, p_tex_bits = 0, i_count = 0, p_count = 0, skip_count = 0, misc_bits = 0, frame_bits = 0, stats_out = 0x0, stats_in = 0x0, workaround_bugs = 1, strict_std_compliance = 0, error_concealment = 3, debug = 0, err_recognition = 0, reordered_opaque = -9223372036854775808, hwaccel = 0x0, hwaccel_context = 0x0, error = {0, 0, 0, 0, 0, 0, 0, 0}, dct_algo = 0, idct_algo = 0, bits_per_coded_sample = 0, bits_per_raw_sample = 0, lowres = 0, coded_frame = 0x668000, thread_count = 0, thread_type = 0, active_thread_type = 0, thread_safe_callbacks = 0, execute = 0x7ffff6dc5a80 , execute2 = 0x7ffff6dc5b00 , nsse_weight = 8, profile = -99, level = -99, skip_loop_filter = AVDISCARD_DEFAULT, skip_idct = AVDISCARD_DEFAULT, skip_frame = AVDISCARD_DEFAULT, subtitle_header = 0x0, subtitle_header_size = 0, vbv_delay = 0, side_data_only_packets = 1, initial_padding = 0, framerate = {num = 30, den = 1}, sw_pix_fmt = AV_PIX_FMT_NONE, pkt_timebase = {num = 0, den = 1}, codec_descriptor = 0x7ffff75d2d00, pts_correction_num_faulty_pts = 0, pts_correction_num_faulty_dts = 0, pts_correction_last_pts = -9223372036854775808, pts_correction_last_dts = -9223372036854775808, sub_charenc = 0x0, sub_charenc_mode = 0, skip_alpha = 0, seek_preroll = 0, debug_mv = 0, chroma_intra_matrix = 0x0, dump_separator = 0x0, codec_whitelist = 0x0, properties = 0, coded_side_data = 0x81bc60, nb_coded_side_data = 1, hw_frames_ctx = 0x0, sub_text_format = 0, trailing_padding = 0, max_pixels = 2147483647, hw_device_ctx = 0x0, hwaccel_flags = 1, apply_cropping = 1, extra_hw_frames = -1} (gdb) p ofmt_ctx $18 = {av_class = 0x7ffff6754bc0, iformat = 0x0, oformat = 0x7ffff6767c80, priv_data = 0x66c080, pb = 0x66d7c0, ctx_flags = 0, nb_streams = 1, streams = 0x66bda0, filename = '\000' <repeats 1023 times>, url = 0x66b470 "", start_time = 0, duration = 0, bit_rate = 0, packet_size = 0, max_delay = -1, flags = 2097152, probesize = 5000000, max_analyze_duration = 0, key = 0x0, keylen = 0, nb_programs = 0, programs = 0x0, video_codec_id = AV_CODEC_ID_NONE, audio_codec_id = AV_CODEC_ID_NONE, subtitle_codec_id = AV_CODEC_ID_NONE, max_index_size = 1048576, max_picture_buffer = 3041280, nb_chapters = 0, chapters = 0x0, metadata = 0x667080, start_time_realtime = -9223372036854775808, fps_probe_size = -1, error_recognition = 1, interrupt_callback = {callback = 0x0, opaque = 0x0}, debug = 0, max_interleave_delta = 10000000, strict_std_compliance = 0, event_flags = 0, max_ts_probe = 50, avoid_negative_ts = 1, ts_id = 0, audio_preload = 0, max_chunk_duration = 0, max_chunk_size = 0, use_wallclock_as_timestamps = 0, avio_flags = 0, duration_estimation_method = AVFMT_DURATION_FROM_PTS, skip_initial_bytes = 0, correct_ts_overflow = 1, seek2any = 0, flush_packets = -1, probe_score = 0, format_probesize = 1048576, codec_whitelist = 0x0, format_whitelist = 0x0, internal = 0x663740, io_repositioned = 0, video_codec = 0x0, audio_codec = 0x0, subtitle_codec = 0x0, data_codec = 0x0, metadata_header_padding = -1, opaque = 0x0, control_message_cb = 0x0, output_ts_offset = 0, dump_separator = 0x660f60 ", ", data_codec_id = AV_CODEC_ID_NONE, open_cb = 0x0, protocol_whitelist = 0x0, io_open = 0x7ffff6468760, io_close = 0x7ffff6468750, protocol_blacklist = 0x0, max_streams = 1000} (gdb) n

Thread 1 "rtmp-stream" received signal SIGBUS, Bus error. malloc_consolidate (av=av@entry=0x7ffff4759b20 ) at malloc.c:4181 4181 malloc.c: No such file or directory. (gdb)`

thean I found the parameters values are not abnormal, but I am not sure

berli commented 6 years ago

I add the cv::resize after the cam>>image by reference the issue https://github.com/jkuri/opencv-ffmpeg-rtmp-stream/issues/1 and still throw the same error , and bt , the heap and stack information are following:

Thread 1 "rtmp-stream" received signal SIGABRT, Aborted. 0x00007ffff1ad2428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54 54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) bt

0 0x00007ffff1ad2428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54

1 0x00007ffff1ad402a in __GI_abort () at abort.c:89

2 0x00007ffff1b147ea in __libc_message (do_abort=2, fmt=fmt@entry=0x7ffff1c2ded8 " Error in `%s': %s: 0x%s \n")

at ../sysdeps/posix/libc_fatal.c:175

3 0x00007ffff1b1f13e in malloc_printerr (ar_ptr=0x7ffff1e61b20 , ptr=0xe01170,

str=0x7ffff1c2ad3f "malloc(): memory corruption", action=<optimized out>) at malloc.c:5006

4 _int_malloc (av=av@entry=0x7ffff1e61b20 , bytes=bytes@entry=16272) at malloc.c:3474

5 0x00007ffff1b1fc0a in _int_memalign (av=av@entry=0x7ffff1e61b20 , alignment=alignment@entry=32, bytes=bytes@entry=16192)

at malloc.c:4421

6 0x00007ffff1b21b44 in _mid_memalign (address=, bytes=16192, alignment=32) at malloc.c:3120

7 __GI___libc_memalign (alignment=, bytes=16192) at malloc.c:3071

8 0x00007ffff0f99eea in x264_malloc () from /usr/lib/x86_64-linux-gnu/libx264.so.148

9 0x00007ffff0f8ad5d in ?? () from /usr/lib/x86_64-linux-gnu/libx264.so.148

10 0x00007ffff0f8f3f8 in x264_frame_pop_unused () from /usr/lib/x86_64-linux-gnu/libx264.so.148

11 0x00007ffff101785a in x264_encoder_encode () from /usr/lib/x86_64-linux-gnu/libx264.so.148

12 0x00007ffff6bcd8a3 in ?? () from /usr/local/lib/libavcodec.so.58

13 0x00007ffff69b4fbc in avcodec_encode_video2 () from /usr/local/lib/libavcodec.so.58

14 0x00007ffff69b5295 in ?? () from /usr/local/lib/libavcodec.so.58

15 0x00007ffff69b5417 in avcodec_send_frame () from /usr/local/lib/libavcodec.so.58

16 0x0000000000404cf5 in write_frame (codec_ctx=0x66a1c0, fmt_ctx=0x664cc0, frame=0x81d000)

at /home/berli/Test/camera-opencv-ffmpeg-rtmp-stream/src/rtmp-stream.cpp:133

17 0x000000000040538c in stream_video (width=800, height=600, fps=30, camID="0", bitrate=300000, codec_profile="high444",

server="rtmp://localhost/live/stream") at /home/berli/Test/camera-opencv-ffmpeg-rtmp-stream/src/rtmp-stream.cpp:213

18 0x0000000000406434 in main (argc=1, argv=0x7fffffffdcf8) at /home/berli/Test/camera-opencv-ffmpeg-rtmp-stream/src/rtmp-stream.cpp:269

(gdb)