Operating System - Linux
1830060 Members
2560 Online
109998 Solutions
New Discussion

Re: dos2unix : segmentation fault.

 
GnanaShekar
Regular Advisor

dos2unix : segmentation fault.

Hi,

I am getting segmentation fault using dos2unix command, please suggest.

[tchintal@bngddia5 ~]$ more /etc/redhat-release
Red Hat Enterprise Linux AS release 4 (Nahant Update 3)

[tchintal@bngddia5 wls]$ pwd
/home/tchintal/tools_stage/783464/dev/src_stable/wls

[tchintal@bngddia5 wls]$ dos2unix infra/build/check_files.sh
dos2unix: converting file infra/build/check_files.sh to UNIX format ...
Segmentation fault

Thanks & Regards,
8 REPLIES 8
Vitaly Karasik_1
Honored Contributor

Re: dos2unix : segmentation fault.

do you have free disk space?
GnanaShekar
Regular Advisor

Re: dos2unix : segmentation fault.

Hi,

We have enough space.

[tchintal@bngddia5 home]$ df -H
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 73G 66G 3.5G 95% /
/dev/sda1 1.1G 11M 1.1G 2% /boot/efi
none 4.3G 0 4.3G 0% /dev/shm
/dev/sdb1 138G 103G 28G 79% /disk1
GnanaShekar
Regular Advisor

Re: dos2unix : segmentation fault.

[tchintal@bngddia5 wls]$ strace dos2unix infra/build/check_files.sh
execve("/usr/bin/dos2unix", ["dos2unix", "infra/build/check_files.sh"], [/* 26 vars */]) = 0
uname({sys="Linux", node="bngddia5", ...}) = 0
brk(0) = 0x6000000000008000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=113522, ...}) = 0
mmap(NULL, 113522, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2000000000044000
close(3) = 0
open("/lib/tls/libc.so.6.1", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0002\0\1\0\0\0`\226\2"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2690949, ...}) = 0
mmap(NULL, 2523696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2000000000060000
mprotect(0x20000000002b0000, 98864, PROT_NONE) = 0
mmap(0x20000000002bc000, 49152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x24c000) = 0x20000000002bc000
mmap(0x20000000002c8000, 560, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x20000000002c8000
close(3) = 0
mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x20000000002cc000
mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x20000000002d0000
munmap(0x2000000000044000, 113522) = 0
brk(0) = 0x6000000000008000
brk(0x600000000002c000) = 0x600000000002c000
write(2, "dos2unix: converting file infra/"..., 72dos2unix: converting file infra/build/check_files.sh to UNIX format ...
) = 72
stat("infra/build/check_files.sh", {st_mode=S_IFREG|0644, st_size=251, ...}) = 0
gettimeofday({1156953666, 158658}, NULL) = 0
getpid() = 6592
open("infra/build/d2utmpmjqlZI", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
fchmod(3, 0100644) = 0
--- SIGSEGV (Segmentation fault) @ 20000000001290e1 (75622f6172666e81) ---
+++ killed by SIGSEGV +++
Process 6592 detached
Vitaly Karasik_1
Honored Contributor

Re: dos2unix : segmentation fault.

do you have write permission to infra/build/check_files.sh?
Mike Stroyan
Honored Contributor

Re: dos2unix : segmentation fault.

That looks like a buffer overflow inside dos2unix. The address that strace reports the program trying to access looks like it is a string that overwrote a pointer.
"0x75622f6172666e81" = "ub/arfn�"
(That last byte is not an ascii character. It was probably a pointer offset from the string value.)
James R. Ferguson
Acclaimed Contributor

Re: dos2unix : segmentation fault.

Hi:

As a workaraound, this Perl script will accomplish the same Dos-to-Unix file conversion.

# perl -ni.old -e 's/\r\n/\n/s;s/\032//s;print' file

...A backup copy "file.old" is automatically created and "file" is filtered.

Regards!

...JRF...
Vitaly Karasik_1
Honored Contributor

Re: dos2unix : segmentation fault.

BTW, there are many alternatives to dos2unix utility: vi, tr and so on.
GnanaShekar
Regular Advisor

Re: dos2unix : segmentation fault.

Hi,

This is myterious issue in linux. Howerver dos2unix works fine if we run it from within the directory that contains files, we want to convert.

Thanks & Regards,