LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-25-2009, 05:28 PM   #1
Efo
LQ Newbie
 
Registered: Nov 2004
Distribution: Gentoo
Posts: 22

Rep: Reputation: 1
#0 0xb7873b71 in memcpy () from /lib/tls/i686/cmov/libc.so.6


Hi guys,

When I compile and link my code on my gentoo box everything works fine and the program runs fine.
At work I have a ubuntu box and I need to run the same code, when I compile and link it everything seems fine; however, when I start it I get a segmentation fault. I use gfortran and upon checking with gdb I get:

(gdb) bt
#0 0xb7d94b6a in memcpy () from /lib/tls/i686/cmov/libc.so.6
#1 0xb7f4a653 in *_gfortrani_write_a (dtp=0xbf98d558, f=0x9f6f59c,
source=0xbf98d688 'Hello \000', len=8) at /usr/include/bits/string3.h:52
#2 0xb7f42cb8 in formatted_transfer_scalar (dtp=0xbf98d558,
type=<error reading variable>, p=0xbf98d688, len=8, size=8)
at ../../../src/libgfortran/io/transfer.c:1041
#3 0xb7f4305e in formatted_transfer (dtp=0xbf98d558,
type=<error reading variable>, p=0xbf98d688, kind=8, size=8, nelems=1)
at ../../../src/libgfortran/io/transfer.c:1378
#4 0xb7f3f396 in *_gfortran_transfer_character (dtp=0x2, p=0x20f6d515, len=5)
at ../../../src/libgfortran/io/transfer.c:1434
#5 0x0804894b in simple () at simple.f:12
#6 0x080489d9 in main ()
#7 0xb7d32685 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6
#8 0x08048701 in _start ()

Any idea on how I can fix this? Maybe something wrong with libc? By the way, I couldnt figure out how to include libc symbols for debuging in ubuntu.

Any help is highly appreciated.

Thanks in advance.

Efo

Last edited by Efo; 01-26-2009 at 07:10 PM.
 
Old 01-26-2009, 04:18 AM   #2
irey
Member
 
Registered: Jun 2008
Location: Torino, Italy
Posts: 65

Rep: Reputation: 17
It's not always possible for the system to detect an array boundary crossing through segmentation faults. Sometimes it just goes ahead silently.

At first glance I would say that on gentoo it worked just because you were lucky but the problem is still there.

Can you post the guilty code?
 
Old 01-26-2009, 07:18 PM   #3
Efo
LQ Newbie
 
Registered: Nov 2004
Distribution: Gentoo
Posts: 22

Original Poster
Rep: Reputation: 1
Thanks irey,

I simplified the problem and I found:
1) The problem occurs only when out.txt is new (i.e. not there)
2) The problem disappears when I uncomment the second "rewind(7)"
3) The problem disappears if I remove "1x," from the format at 20

What basic mistake am I making?
Here is the code:

program simple
character*8 strngw,strngr
strngw='Hello'

open(unit=7,file='out.txt',status='unknown')
rewind(7)
read(7,20,end=10) strngr
10 continue
c rewind(7)
write(7,20) strngw
close(7)
20 format(1x,a5)
c
return
c
end program simple
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
errno: TLS definition in /lib64/libc.so.6 section .tbss mismatches non-TLS reference johnpaulodonnell Programming 2 07-25-2008 05:37 AM
what is the meaning of /lib/tls directory? voger Fedora 2 11-25-2005 06:56 PM
gcc i686 libc xiaoyuer18 Linux - Distributions 0 10-12-2005 06:19 PM
libc.so.6 not in /lib - how to fix? Battlefield Linux - General 1 03-25-2005 10:28 PM
xauth: /lib/i686/libc.so.6: version 'GLIBC_2.3.2' not found yigald Linux - Newbie 0 02-21-2004 12:52 AM


All times are GMT -5. The time now is 11:08 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration