Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When i build picam, i got this error. #144

Open
joelihn opened this issue Sep 11, 2020 · 4 comments
Open

When i build picam, i got this error. #144

joelihn opened this issue Sep 11, 2020 · 4 comments

Comments

@joelihn
Copy link

joelihn commented Sep 11, 2020

`cc stream.o hooks.o mpegts.o httplivestreaming.o state.o log.o text.o timestamp.o subtitle.o dispmanx.o -o picam -g -Wl,--whole-archive -lilclient -L/opt/vc/lib/ -L/usr/local/lib -lbrcmGLESv2 -lbrcmEGL -lopenmaxil -lbcm_host -lvcos -lvchiq_arm -lpthread -lrt -L/opt/vc/src/hello_pi/libs/ilclient -Wl,--no-whole-archive -rdynamic -lm -lcrypto -lasound `pkg-config --libs freetype2` `pkg-config --libs harfbuzz fontconfig libavformat libavcodec`
/usr/bin/ld: /usr/local/lib/libavformat.a(fifo.o): in function `fifo_init':
/home/pi/Joe/picam/ffmpeg/libavformat/fifo.c:519: undefined reference to `__atomic_store_8'
/usr/bin/ld: /usr/local/lib/libavformat.a(fifo.o): in function `fifo_write_trailer':
/home/pi/Joe/picam/ffmpeg/libavformat/fifo.c:624: undefined reference to `__atomic_fetch_add_8'
/usr/bin/ld: /home/pi/Joe/picam/ffmpeg/libavformat/fifo.c:631: undefined reference to `__atomic_store_8'
/usr/bin/ld: /usr/local/lib/libavformat.a(fifo.o): in function `fifo_thread_write_packet':
/home/pi/Joe/picam/ffmpeg/libavformat/fifo.c:188: undefined reference to `__atomic_fetch_sub_8'
/usr/bin/ld: /usr/local/lib/libavformat.a(fifo.o): in function `fifo_consumer_thread':
/home/pi/Joe/picam/ffmpeg/libavformat/fifo.c:457: undefined reference to `__atomic_load_8'
/usr/bin/ld: /usr/local/lib/libavformat.a(fifo.o): in function `fifo_write_packet':
/home/pi/Joe/picam/ffmpeg/libavformat/fifo.c:597: undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make: *** [Makefile:26:picam] 错误 1
`
@joelihn
Copy link
Author

joelihn commented Sep 11, 2020

After add -latomic to LDFLAGS, i can build picam.

But when i run the program, it crashed.

Here is the information:


pi@raspberrypi:~/Joe/picam $ gdb --args ./picam -o /run/shm/hls --hlsenc --hlsenckeyuri enc.key   --hlsenckey f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff   --hlsenciv 000102030405060708090a0b0c0d0e0f --alsadev hw:2,0
GNU gdb (Raspbian 8.2.1-2) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./picam...done.
(gdb) run
Starting program: /home/pi/Joe/picam/picam -o /run/shm/hls --hlsenc --hlsenckeyuri enc.key --hlsenckey f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff --hlsenciv 000102030405060708090a0b0c0d0e0f --alsadev hw:2,0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[New Thread 0xb61aa420 (LWP 1128)]
configuring devices
[New Thread 0xb57ff420 (LWP 1129)]
[New Thread 0xb4dff420 (LWP 1130)]
[New Thread 0xb45fe420 (LWP 1131)]
[New Thread 0xb3dfd420 (LWP 1132)]
[New Thread 0xb35fc420 (LWP 1133)]
[New Thread 0xb2dfb420 (LWP 1134)]
capturing started

Thread 8 "ILCS_HOST" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb2dfb420 (LWP 1134)]
0x000cf2e4 in hls_write_packet (hls=0x16deba8, pkt=0xb2dfab90, pkt@entry=0x0, split=<optimized out>) at httplivestreaming.c:351
351	        pmt_cc = ts_st->service->pmt.cc;
(gdb) bt
#0  0x000cf2e4 in hls_write_packet (hls=0x16deba8, pkt=0xb2dfab90, pkt@entry=0x0, split=<optimized out>) at httplivestreaming.c:351
#1  0x000cc144 in send_keyframe (consume_time=<optimized out>, data_len=<optimized out>, data=0xdf70f0 <encoded_packets_size> "p\003") at stream.c:2235
#2  video_encode_fill_buffer_done (out=0x170c9f0) at stream.c:3747
#3  encode_and_send_image () at stream.c:4141
#4  cam_fill_buffer_done (data=<optimized out>, comp=<optimized out>) at stream.c:3077
#5  0x000d7104 in ilclient_fill_buffer_done (hComponent=0x16eb820, pAppData=0x16eb770, pBuffer=0x16ec460) at ilclient.c:1736
#6  0xb6f14108 in vcil_out_fill_buffer_done () from /opt/vc/lib/libopenmaxil.so
#7  0xb6f10fd8 in ilcs_command () from /opt/vc/lib/libopenmaxil.so
#8  0xb6f11e40 in ilcs_task () from /opt/vc/lib/libopenmaxil.so
#9  0xb6ececb0 in vcos_thread_entry (arg=0x16e15e8) at /home/dom/projects/staging/userland/interface/vcos/pthreads/vcos_pthreads.c:144
#10 0xb6e92494 in start_thread (arg=0xb2dfb420) at pthread_create.c:486
#11 0xb65cb578 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:73 from /lib/arm-linux-gnueabihf/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) where
#0  0x000cf2e4 in hls_write_packet (hls=0x16deba8, pkt=0xb2dfab90, pkt@entry=0x0, split=<optimized out>) at httplivestreaming.c:351
#1  0x000cc144 in send_keyframe (consume_time=<optimized out>, data_len=<optimized out>, data=0xdf70f0 <encoded_packets_size> "p\003") at stream.c:2235
#2  video_encode_fill_buffer_done (out=0x170c9f0) at stream.c:3747
#3  encode_and_send_image () at stream.c:4141
#4  cam_fill_buffer_done (data=<optimized out>, comp=<optimized out>) at stream.c:3077
#5  0x000d7104 in ilclient_fill_buffer_done (hComponent=0x16eb820, pAppData=0x16eb770, pBuffer=0x16ec460) at ilclient.c:1736
#6  0xb6f14108 in vcil_out_fill_buffer_done () from /opt/vc/lib/libopenmaxil.so
#7  0xb6f10fd8 in ilcs_command () from /opt/vc/lib/libopenmaxil.so
#8  0xb6f11e40 in ilcs_task () from /opt/vc/lib/libopenmaxil.so
#9  0xb6ececb0 in vcos_thread_entry (arg=0x16e15e8) at /home/dom/projects/staging/userland/interface/vcos/pthreads/vcos_pthreads.c:144
#10 0xb6e92494 in start_thread (arg=0xb2dfb420) at pthread_create.c:486
#11 0xb65cb578 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:73 from /lib/arm-linux-gnueabihf/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) 

@marler8997
Copy link
Contributor

I just tried to build and got the exact same backtrace. My guess is it's a problem with the ffmpeg version I built? The docs for BUILDING.md don't specify a version and/or commit to build from. Could be a red herring but it seems like the most likely culprit at the moment. I'll try to update you if I learn more.

marler8997 added a commit to marler8997/picam that referenced this issue Jan 22, 2021
I removed all the fields that were not being used from the MpegTS* structs.  Then I looked at the differences between the struct definitions between what was committed and what was in the ffmpeg repo. For the difference that mattered I checked the git history and added a version check to include the field.

Futhermore, the MpegTSWriteStream struct supposedly contained a pointer to a MpegTSService struct, however, I could not find any version of ffmpeg where this field exists.  I removed it and removed the 2 references to it.

After these changes, I'm able to build picam and I no longer get a segfault in hls_write_packet when dereferencing ts_st->service (see a backtrace here iizukanao#144 (comment)).
marler8997 added a commit to marler8997/picam that referenced this issue Jan 22, 2021
I removed all the fields that were not being used from the MpegTS* structs.  Then I looked at the differences between the struct definitions between what was committed and what was in the ffmpeg repo. For the difference that mattered I checked the git history and added a version check to include the field.

Futhermore, the MpegTSWriteStream struct supposedly contained a pointer to a MpegTSService struct, however, I could not find any version of ffmpeg where this field exists.  I removed it and removed the 2 references to it.

After these changes, I'm able to build picam and I no longer get a segfault in hls_write_packet when dereferencing ts_st->service (see a backtrace here iizukanao#144 (comment)).
@marler8997
Copy link
Contributor

This PR should fix the segfault: #153

You can get around the requirement for -latomic by using ffmpeg version 4.3. We should update BUILDING.md to reflect what version of ffmpeg to pull.

@marler8997
Copy link
Contributor

marler8997 commented Jan 22, 2021

And this PR should clarify what version of ffmpeg to build so you don't get the undefined reference errors for missing -latomic: #155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants