Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 169453 - media-sound/timidity++-2.13.2-r3: timidity crashes during the boot process
Summary: media-sound/timidity++-2.13.2-r3: timidity crashes during the boot process
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo Sound Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-05 14:11 UTC by Paulo da Silva
Modified: 2012-04-19 21:50 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paulo da Silva 2007-03-05 14:11:06 UTC
This is a strange problem. timidity crashes when the /etc/init.d/timidity is
executed during the boot process. If later I restart it using /etc/init.d/timidity
it stays running normally.

I digged a little replacing part of the script as follows

start() {
	ebegin "Starting Timidity Virtual Midi Sequencer"
	test -n "$TIMIDITY_PCM_NAME" && export TIMIDITY_PCM_NAME
	while [ ! -r /usr/share/timidity/timidity.cfg ]; do
		sleep 2
	done
	nohup /usr/bin/timidity -iA ${TIMIDITY_OPTS} &> /root/tmp/timidity.LOG &
	eend $?
}

and got the following log:

/usr/share/timidity/timidity.cfg: No such file or directory
timidity: Can't read any configuration file.
Please check /usr/share/timidity/timidity.cfg

I just put the while loop in the script to be sure the config file
exists and is read available.

There must be something wrong with the timidity code. It is reporting the
wrong condition or it is checking for the config file existence in a way
that somehow does not work when booting (too much load?).

BTW, the PC where this occurs is a laptop with a relatively slow HD.


Reproducible: Always
Comment 1 Stian Skjelstad 2007-07-19 07:10:12 UTC
do you still have this issue?

If so, could you install strace and try to

strace -o log -ff -F /usr/bin/timidity -iA ${TIMIDITY_OPTS}


That will give is a great idea about what is happening with that strange little beast. Also, please provide the output from emerge --info
Comment 2 Paulo da Silva 2007-07-19 17:18:41 UTC
(In reply to comment #1)
> do you still have this issue?
YES!
> 
> If so, could you install strace and try to
> 
> strace -o log -ff -F /usr/bin/timidity -iA ${TIMIDITY_OPTS}
> 
I have strace installed.
> 
> That will give is a great idea about what is happening with that strange little
> beast. Also, please provide the output from emerge --info
> 

There is a lot of info to post. For security reasons I would send that information by email if it is absolutely needed.

In the meanwhile, I'll post here what I think is relevant.

When launched during the boot process, timidity states "~/usr/share/timidity/timidity.cfg" (note the '~') which does not exist while when launched by root, after boot is complete it states "/usr/share/timidity/timidity.cfg" (without '~') which exists even if it later also checks "~/usr/share/timidity/timidity.cfg".

Another point is that the file /etc/passwd is not open while booting.

Here is both logs parts:

During boot
...
open("/etc/passwd", O_RDONLY)           = 3
fcntl64(3, F_GETFD)                     = 0
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
_llseek(3, 0, [0], SEEK_CUR)            = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=2598, ...}) = 0
mmap2(NULL, 2598, PROT_READ, MAP_SHARED, 3, 0) = 0xb7f09000
_llseek(3, 2598, [2598], SEEK_SET)      = 0
munmap(0xb7f09000, 2598)                = 0
close(3)                                = 0
time(NULL)                              = 1184862129
stat64("-iA", 0xbfc8ca68)               = -1 ENOENT (No such file or directory)
stat64("-B2,8", 0xbfc8ca68)             = -1 ENOENT (No such file or directory)
stat64("-Os", 0xbfc8ca68)               = -1 ENOENT (No such file or directory)
stat64("-EFreverb=0", 0xbfc8ca68)       = -1 ENOENT (No such file or directory)
stat64("~/usr/share/timidity/timidity.cfg", 0xbfc8c2c8) = -1 ENOENT (No such file or directory)
write(2, "/usr/share/timidity/timidity.cfg"..., 59) = 59
write(2, "\n", 1)                       = 1
open("//.timidity.cfg", O_RDONLY)       = -1 ENOENT (No such file or directory)
open("/usr/lib/timidity/interface_A.so", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "timidity: Can\'t read any configu"..., 90) = 90
write(2, "\n", 1)                       = 1
exit_group(1)                           = ?
>>>EOF<<<

After boot from root
...
stat64("-iA", 0xbff3f9a8)               = -1 ENOENT (No such file or directory)
stat64("-B2,8", 0xbff3f9a8)             = -1 ENOENT (No such file or directory)
stat64("-Os", 0xbff3f9a8)               = -1 ENOENT (No such file or directory)
stat64("-EFreverb=0", 0xbff3f9a8)       = -1 ENOENT (No such file or directory)
stat64("/usr/share/timidity/timidity.cfg", {st_mode=S_IFREG|0644, st_size=669, ...}) = 0
open("/usr/share/timidity/timidity.cfg", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=669, ...}) = 0
mmap2(NULL, 669, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f5a000
close(3)                                = 0
stat64("current/timidity.cfg", 0xbff3eab8) = -1 ENOENT (No such file or directory)
open("current/timidity.cfg", O_RDONLY)  = -1 ENOENT (No such file or directory)
stat64("~/.timidity/current/timidity.cfg", 0xbff3eab8) = -1 ENOENT (No such file or directory)
open("/root/.timidity/current/timidity.cfg", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=248, ...}) = 0
mmap2(NULL, 248, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f59000
close(3)                                = 0
... continue ...
Comment 3 Stian Skjelstad 2007-07-19 19:40:57 UTC
Started to look at the source, and they seem to use a wacky function:

url_unexpand_home_dir()

And it will make that wierd path if your $HOME is set to "/", so either unset $HOME or set $HOME to /root.

Up-stream should probably be asked about the somewhat strange schematic of url_unexpand_home_dir(), and why it is used in functions that will send the result to open() that doesn't support ~ syntax at all.
Comment 4 Paulo da Silva 2007-07-20 00:45:24 UTC
OK. Changing the init script to
...
	HOME=/root
	start-stop-daemon --start --quiet --background \
		--make-pidfile --pidfile /var/run/timidity.pid \
		--exec /usr/bin/timidity -- -iA ${TIMIDITY_OPTS}
...
fixes the problem.
I don't have to restart timidity again.
Thanks
Comment 5 Diego Elio Pettenò (RETIRED) gentoo-dev 2007-11-24 15:44:04 UTC
Please test -r6, it should now work. If the bug is fixed, please CLOSE the bug.
Comment 6 Paulo da Silva 2007-11-25 18:13:16 UTC
(In reply to comment #5)
> Please test -r6, it should now work. If the bug is fixed, please CLOSE the bug.
> 

I tried it. This is what I got:

1. The original problem seems to be fixed.
2. After emerge, timidity does not keep running.
3. I added "timidity" to group audio (18) and
    a) It runs after booting but
    b) If I stop the "service" and then start it again, as root, (/etc/init.d/tmidity stop/start) it stops but does not start!
4. I removed "--chuid timidity:nobody" from /etc/init.d/tmidity and it works as expected.
Comment 7 Stian Skjelstad 2007-11-26 09:10:06 UTC
Could you try this:

HOME=/tmp /etc/init.d/timitidy restart

(let HOME by anything but empty or /)


and if possible provide new strace output if the issue remains the same (my experience is that timitidy has some strange behavior regarding of the $HOME environment variable, and I'm a bit curious)
Comment 8 Paulo da Silva 2007-11-26 22:36:12 UTC
(In reply to comment #7)
> Could you try this:
> 
> HOME=/tmp /etc/init.d/timitidy restart
> 
Does not work.

I also tried to put the line
HOME=/root
in the /etc/init.d/timidity script, as I did in the previous version I have been using so far. It does not work either.

I only got it to work by removing "--chuid timidity:nobody" from the script.


> and if possible provide new strace output

About strace ...
I need to know how to run "strace /usr/bin/timidity" under timidity:nobody.

Can you help me?

Thanks
Comment 9 Paulo da Silva 2007-11-28 03:48:38 UTC
I tried as follows:

As root
# chown timidity:nobody /usr/bin/timidity
# chmod ug+s /usr/bin/timidity

As my user
$ /usr/bin/timidity -iA -B2,8 -Os -EFreverb=0
~/.timidity/current/timidity.cfg: Permission denied (=== the problem seems to be here ===)
timidity: Can't read any configuration file.
Please check /usr/share/timidity/timidity.cfg

$ HOME=/tmp /usr/bin/timidity -iA -B2,8 -Os -EFreverb=0
Requested buffer size 2048, fragment size 1024
ALSA pcm 'default' set buffer size 2048, period size 1024 bytes
TiMidity starting in ALSA server mode
Opening sequencer port: 128:0 128:1 128:2 128:3

CTRL+C

HTH
Comment 10 Sergey Torokhov 2012-04-19 19:34:50 UTC
I have the same problem with media-sound/timidity++-2.13.2-r13

After boot process "#/etc/init.d/timidity status" return "crashed" and 

"#aplaymidi -l" return:
 Port    Client name                      Port name
 14:0    Midi Through                     Midi Through Port-0


If I start timidity manualy by "#/etc/init.d/timidity start"  then
# /etc/init.d/timidity start
 * Caching service dependencies                  [ ok ]
 * Starting TiMidity++ Virtual Midi Sequencer    [ ok ]

and "#aplaymidi -l" return:
 Port    Client name                      Port name
 14:0    Midi Through                     Midi Through Port-0
128:0    TiMidity                         TiMidity port 0
128:1    TiMidity                         TiMidity port 1
128:2    TiMidity                         TiMidity port 2
128:3    TiMidity                         TiMidity port 3


my /etc/init.d/timidity script is "default" (--chuid only changed to --user):

...
start() {
        ebegin "Starting TiMidity++ Virtual Midi Sequencer"
        test -n "$TIMIDITY_PCM_NAME" && export TIMIDITY_PCM_NAME
        start-stop-daemon --start --background --chdir /usr/share/timidity \
        --user timidity:audio --make-pidfile --pidfile /var/run/timidity.pid \
        --exec /usr/bin/timidity -- -iA ${TIMIDITY_OPTS}
        eend $?
...
Comment 11 Sergey Torokhov 2012-04-19 21:50:11 UTC
it strange that #eselect timidity change "~current" symlink only in "/root/.timidity" directory while there is a strange "~current" symlink in the "/usr/share/timidity" that refers to "//usr/share/timidity/eawpatches/" (Note "//" in the begining of path). I changed it manualy to "/usr/share/timidity/eawpatches/" but timidity is still crushes on boot.

My "/etc/timidity.cfg" is:

...
dir /usr/share/timidity
dir ~/.timidity
source current/timidity.cfg

and I tried also to change it to
...
dir ~/.timidity
dir /usr/share/timidity
source current/timidity.cfg
...


Also there was a problen (https://bugs.gentoo.org/show_bug.cgi?id=204727)
with  media-sound/timidity++-2.13.2-r6 initscript but it seems that that resolving already was includeв to my init script.