public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/58104] New: std::call_once appears to fail on standard code
@ 2013-08-08 16:03 barto at visionpro dot com
2013-08-08 16:10 ` [Bug libstdc++/58104] " redi at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: barto at visionpro dot com @ 2013-08-08 16:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58104
Bug ID: 58104
Summary: std::call_once appears to fail on standard code
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: barto at visionpro dot com
When using std::call_once the code on Linux(gcc 4.7.0) or MacOS (gcc 4.7.3 or
4.8.1) fails to execute
562_ /opt/local/bin/gcc-mp-4.8 -v
Using built-in specs.
COLLECT_GCC=/opt/local/bin/gcc-mp-4.8
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin12/4.8.1/lto-wrapper
Target: x86_64-apple-darwin12
Configured with: ../gcc-4.8.1/configure --prefix=/opt/local
--build=x86_64-apple-darwin12
--enable-languages=c,c++,objc,obj-c++,lto,fortran,java
--libdir=/opt/local/lib/gcc48 --includedir=/opt/local/include/gcc48
--infodir=/opt/local/share/info --mandir=/opt/local/share/man
--datarootdir=/opt/local/share/gcc-4.8 --with-local-prefix=/opt/local
--with-system-zlib --disable-nls --program-suffix=-mp-4.8
--with-gxx-include-dir=/opt/local/include/gcc48/c++/ --with-gmp=/opt/local
--with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local
--with-cloog=/opt/local --enable-cloog-backend=isl
--disable-cloog-version-check --enable-stage1-checking --enable-lto
--enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld
--with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket
--with-pkgversion='MacPorts gcc48 4.8.1_1+universal'
Thread model: posix
gcc version 4.8.1 (MacPorts gcc48 4.8.1_1+universal)
The code that fails is taken directly from the c++ documentation site:
http://en.cppreference.com/w/cpp/thread/call_once
#include <iostream>
#include <thread>
#include <mutex>
std::once_flag flag;
void do_once()
{
std::call_once(flag, [](){ std::cout << "Called once" << std::endl; });
}
int main()
{
std::thread t1(do_once);
std::thread t2(do_once);
std::thread t3(do_once);
std::thread t4(do_once);
t1.join();
t2.join();
t3.join();
t4.join();
}
The bug appears in the call to call_once (thanks for detail from Jeremy
Huddleston Sequoia on the MacPorts mailing list for the assembly trace)
__once_proxy is just looking up some other function (__once_call) using
__emutls_get_address and executing it (makes sense based on the name).
__emutls_get_address is returning 3 in this instance, so something looks wrong
with emutls:
(lldb) disassemble -n __once_proxy
libstdc++.6.dylib`__once_proxy:
0x1000e974e: pushq %rbp
0x1000e974f: movq %rsp, %rbp
0x1000e9752: leaq 463719(%rip), %rdi ; __emutls_v._ZSt11
_ZSt11__once_call
0x1000e9759: callq 0x100101880 ;
libstdc++.6.dylib.__TEXT.__text + 602364
-> 0x1000e975e: movq (%rax), %rax
0x1000e9761: callq *%rax
0x1000e9763: popq %rbp
0x1000e9764: ret
(lldb) disassemble -s 0x100101880
libstdc++.6.dylib`__emutls_get_address:
...
(lldb) register read
General Purpose Registers:
rax = 0x0000000000000003
...
Further this has been shown to fail on 4.7 [gcc version 4.7.3 (MacPorts gcc47
4.7.3_1+universal)]
and in the development build for gcc 4.9 (again through Jeremy)
If this is a configuration issue, what configuration flag is required to make
the feature work?
What versions of the Mac/Linux version of gcc have been shown to work?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/58104] std::call_once appears to fail on standard code
2013-08-08 16:03 [Bug libstdc++/58104] New: std::call_once appears to fail on standard code barto at visionpro dot com
@ 2013-08-08 16:10 ` redi at gcc dot gnu.org
2013-08-08 16:15 ` DBarto at visionpro dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2013-08-08 16:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58104
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Works for me.
Are you using the -pthread flag?
You haven't actually said what fails, what fails to execute?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/58104] std::call_once appears to fail on standard code
2013-08-08 16:03 [Bug libstdc++/58104] New: std::call_once appears to fail on standard code barto at visionpro dot com
2013-08-08 16:10 ` [Bug libstdc++/58104] " redi at gcc dot gnu.org
@ 2013-08-08 16:15 ` DBarto at visionpro dot com
2013-08-08 16:20 ` DBarto at visionpro dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: DBarto at visionpro dot com @ 2013-08-08 16:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58104
--- Comment #2 from DBarto at visionpro dot com ---
I added the -pthread flag and nothing changed.
The code failed to execute at the point noted in the assembly output.
David
On Aug 8, 2013, at 9:10 AM, redi at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58104
>
> --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> Works for me.
>
> Are you using the -pthread flag?
>
> You haven't actually said what fails, what fails to execute?
>
> --
> You are receiving this mail because:
> You reported the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/58104] std::call_once appears to fail on standard code
2013-08-08 16:03 [Bug libstdc++/58104] New: std::call_once appears to fail on standard code barto at visionpro dot com
2013-08-08 16:10 ` [Bug libstdc++/58104] " redi at gcc dot gnu.org
2013-08-08 16:15 ` DBarto at visionpro dot com
@ 2013-08-08 16:20 ` DBarto at visionpro dot com
2013-08-08 18:23 ` barto at visionpro dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: DBarto at visionpro dot com @ 2013-08-08 16:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58104
--- Comment #3 from DBarto at visionpro dot com ---
/opt/local/bin/g++-mp-4.7 -std=c++11 -Wall -Wextra -pthread -g use_once.cpp -o
use_once
./use_once
571_ ./use_once
Segmentation fault: 11
gdb use_once
(gdb) r
Starting program: /Users/barto/mvp/trunk/unit_test/use_once
Reading symbols for shared libraries +++.............................. done
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
[Switching to process 22829 thread 0x1203]
0x0000000100074b20 in __once_proxy ()
(gdb) where
#0 0x0000000100074b20 in __once_proxy ()
#1 0x00007fff8f7e0ff0 in pthread_once ()
#2 0x0000000100001165 in __gthread_once (__once=0x1000055e0,
__func=0x100074b10 <__once_proxy>) at gthr-default.h:718
#3 0x000000010000142d in call_once<do_once()::<lambda()> >
(__once=@0x1000055e0, __f=@0x100293e6f) at mutex:822
#4 0x0000000100001247 in do_once () at use_once.cpp:47
#5 0x0000000100002a29 in
_ZNSt12_Bind_simpleIFPFvvEvEE9_M_invokeIIEEEvSt12_Index_tupleIIXspT_EEE
(this=0x100303aa0) at functional:1598
#6 0x0000000100002979 in std::_Bind_simple<void (*()())()>::operator()
(this=0x100303aa0) at functional:1586
#7 0x0000000100002912 in std::thread::_Impl<std::_Bind_simple<void (*()())()>
>::_M_run (this=0x100303a88) at thread:115
#8 0x00000001000754b0 in execute_native_thread_routine ()
#9 0x00007fff8f7cc1e1 in thread_start ()
On Aug 8, 2013, at 9:10 AM, redi at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58104
>
> --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> Works for me.
>
> Are you using the -pthread flag?
>
> You haven't actually said what fails, what fails to execute?
>
> --
> You are receiving this mail because:
> You reported the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/58104] std::call_once appears to fail on standard code
2013-08-08 16:03 [Bug libstdc++/58104] New: std::call_once appears to fail on standard code barto at visionpro dot com
` (2 preceding siblings ...)
2013-08-08 16:20 ` DBarto at visionpro dot com
@ 2013-08-08 18:23 ` barto at visionpro dot com
2013-08-08 23:53 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: barto at visionpro dot com @ 2013-08-08 18:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58104
--- Comment #4 from barto at visionpro dot com ---
Adding the -pthread flag allows the code to compile and execute on Linux.
MacOS still fails to execute.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/58104] std::call_once appears to fail on standard code
2013-08-08 16:03 [Bug libstdc++/58104] New: std::call_once appears to fail on standard code barto at visionpro dot com
` (3 preceding siblings ...)
2013-08-08 18:23 ` barto at visionpro dot com
@ 2013-08-08 23:53 ` redi at gcc dot gnu.org
2013-08-09 0:03 ` barto at visionpro dot com
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2013-08-08 23:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58104
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
"Failed to execute" and "segmentation fault" are not the same thing, it would
help if you actually say what the problem is!
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/58104] std::call_once appears to fail on standard code
2013-08-08 16:03 [Bug libstdc++/58104] New: std::call_once appears to fail on standard code barto at visionpro dot com
` (4 preceding siblings ...)
2013-08-08 23:53 ` redi at gcc dot gnu.org
@ 2013-08-09 0:03 ` barto at visionpro dot com
2013-08-09 9:06 ` [Bug target/58104] " redi at gcc dot gnu.org
2013-08-09 15:29 ` barto at visionpro dot com
7 siblings, 0 replies; 9+ messages in thread
From: barto at visionpro dot com @ 2013-08-09 0:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58104
--- Comment #6 from barto at visionpro dot com ---
Compiling the code listed in the original bug report with gcc4.8 using the
-pthread flag the program fails to complete execution due to a segmentation
fault while attempting to acquire a std::once_flag object in a call to
std::call_once.
This but only occurs on MacOS X builds.
The code works correctly on Linux with the -pthread option to the compiler.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/58104] std::call_once appears to fail on standard code
2013-08-08 16:03 [Bug libstdc++/58104] New: std::call_once appears to fail on standard code barto at visionpro dot com
` (5 preceding siblings ...)
2013-08-09 0:03 ` barto at visionpro dot com
@ 2013-08-09 9:06 ` redi at gcc dot gnu.org
2013-08-09 15:29 ` barto at visionpro dot com
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2013-08-09 9:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58104
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |darwin
Component|libstdc++ |target
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It works ok for others on Mac OS X:
http://gcc.gnu.org/ml/gcc-testresults/2013-07/msg01805.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/58104] std::call_once appears to fail on standard code
2013-08-08 16:03 [Bug libstdc++/58104] New: std::call_once appears to fail on standard code barto at visionpro dot com
` (6 preceding siblings ...)
2013-08-09 9:06 ` [Bug target/58104] " redi at gcc dot gnu.org
@ 2013-08-09 15:29 ` barto at visionpro dot com
7 siblings, 0 replies; 9+ messages in thread
From: barto at visionpro dot com @ 2013-08-09 15:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58104
barto at visionpro dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #8 from barto at visionpro dot com ---
So it is a configuration issue related to MacPorts and not specific to gcc or
the libraries.
Closing the bug at gcc.org.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-08-09 15:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-08 16:03 [Bug libstdc++/58104] New: std::call_once appears to fail on standard code barto at visionpro dot com
2013-08-08 16:10 ` [Bug libstdc++/58104] " redi at gcc dot gnu.org
2013-08-08 16:15 ` DBarto at visionpro dot com
2013-08-08 16:20 ` DBarto at visionpro dot com
2013-08-08 18:23 ` barto at visionpro dot com
2013-08-08 23:53 ` redi at gcc dot gnu.org
2013-08-09 0:03 ` barto at visionpro dot com
2013-08-09 9:06 ` [Bug target/58104] " redi at gcc dot gnu.org
2013-08-09 15:29 ` barto at visionpro dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).