preinit v4 and launcher problems?

Posted by: oliver

preinit v4 and launcher problems? - 05/08/2002 20:04

Hi, I just reinstalled preinit, with the launcher app. Haven't gotten around to installing them after beta13. After i got everything setup, with the slightly modified launcher script. I get this error durning bootup.

Starting launcher...
: No such hijack(9): memory violation at pc=0x020045a0, lr=0x02004548 (bad addre
ss=0x464c4587, code 2)
file or direcpc : [<020045a0>] lr : [<02004548>]
sp : bffffe80 ip : bffffea0 fp : bffffe9c
tory
r10: 020006c8 r9 : 00000000 r8 : 0202f010
r7 : 0203ff30 r6 : 464c457f r5 : 0203ff20 r4 : 00000010
r3 : 00001049 r2 : 00000010 r1 : 00001048 r0 : 464c457f
Flags: nZCv IRQs on FIQs on Mode USER_32 Segment user
Control: C0F8517D Table: C0F8517D DAC: 00000015
Function entered at [<02004578>] from [<02004548>]
r7 = 00000000 r6 = 020000C0 r5 = 0203FF20 r4 = 464C457F
Function entered at [<020044a0>] from [<020009c0>]
r5 = BFFFFF74 r4 = 00000001
Function entered at [<020006c8>] from [<02000b64>]
Function entered at [<02000a88>] from [<02000104>]
r10 = 00000000 r8 = 00000000 r7 = 00000000 r6 = 00000000
r5 = 00000000 r4 = 00000000

Just upgraded to the latest hijack (291) double check everything is 755, and double checked i had the directory right in the launcher script. Here is my slightly modified launcher script (just changed the dir it was looking for.)
#!/bin/sh
echo "Starting launcher..."
/usr/apps/launcher

I used the command line 'edit' program in xp to change the file. I also double checked the file with the file browser userland app included with the launcher.

If i goto /usr/apps/ and type ./launcher the program loads and runs exactly how it should.

How should i go about fixing this error?
Posted by: canuckInOR

Re: preinit v4 and launcher problems? - 06/08/2002 00:15

Hrm... I'm getting that, as well. Does Launcher still run despite that output? In my case, it does...

I don't think it's related to launcher. As a test, I removed all my preinit scripts from the preinit.d directory (except for N01mountdrives, and N02telnetd). I rebooted the player, and got no warning messages. I added M01launcher back in, and got the error again. I took MO1launcher out, and replaced it with M02empacman (which runs /usr/local/bin/empacman). Rebooting again, I get the error.

I've tested with preinit.v3, v4, and v5 beta.

My best guess is that preinit is bulding a list of M scripts to run, and after everything gets started, tries to start a non-existant script -- a potential example of the classic "off by one" error. As a test, I added a bunch of extra preinit scripts that just have "echo starting $0" in them. It doesn't matter how many are in the directory, I only get the error after all of them have been run. Similarly, I don't get the error if there aren't any M scripts at all...

Oh, and in my testing, there is definately something very strange going on with empacman. It immediately yanks all the button bindings and display for itself. It's done that consistently whenever I try launching any other user hijack app.

Cheers,
Posted by: canuckInOR

Re: preinit v4 and launcher problems? - 06/08/2002 00:32

Oh, I just noticed this in your output:

Starting launcher...
: No such hijack(9): memory violation at pc=0x020045a0, lr=0x02004548 (bad addre
ss=0x464c4587, code 2)
file or direcpc : [<020045a0>] lr : [<02004548>]
sp : bffffe80 ip : bffffea0 fp : bffffe9c
tory
r10: 020006c8 r9 : 00000000 r8 : 0202f010


You might be making the same mistake I did in thinking that adding /dev/hda2 to the /etc/fstab is enough to get the partition mounted. As I was duly informed, it's not -- that file is only there to make the df program happy. So I have to ask if you have a preinit script to automatically mount /usr/apps. If you don't have a similar script already, you need an N01mountdrives script:

#!/bin/sh
echo "Mounting /usr/apps..."
mount -n -o ro /usr/apps
exit

Give that a whirl, and see if that solves your problem...

Cheers,
Posted by: wfaulk

Re: preinit v4 and launcher problems? - 06/08/2002 03:55

So you can get this error even if the only scripts you have just echo stuff? Nuts. I guess it is my problem. I've never seen it on mine, though.

Can you give me an example of exactly what you have in your preinit.d directory?
Posted by: canuckInOR

Re: preinit v4 and launcher problems? - 06/08/2002 09:33

Tarball attached...

When I get rid of all the M scripts, I get rid of the error. As soon as I put one of the M scripts in, the error comes back.

Posted by: oliver

Re: preinit v4 and launcher problems? - 06/08/2002 09:41

I haven't bothered formatting the 32mb dev partition yet. I just made a new directory in usr, this is how i've done it before but without the launcher. I tried that that script, even though i didn't need it before (when beta 11 was on my empeg) Just in case it might have solved my problem. But nope, still same error message.

The Launcher does not run, i have to go type ./launcher in my apps directory in order to get it to bind to the hijack menu.

EDIT: The only thing i have preinit v4 starting is the launcher. The M01launcher script is the only thing in my directory, well now i also have that mountdrive script, but i'm about to delete it because it didn't work.

Any other ideas on how to solve this problem?
Posted by: wfaulk

Re: preinit v4 and launcher problems? - 06/08/2002 11:43

So if any one of the M scripts is there, you get that error?

The first problem I see is that the launcher is in /usr/local/bin. Is that directory on a mounted filesystem?

I guess it is. You said it still ran, right?

Edit: Oh. M. Nevermind. My head's screwed on wrong. Gimme a few to test it.
Posted by: canuckInOR

Re: preinit v4 and launcher problems? - 06/08/2002 20:10

Wild speculation here, since I can't think of anything else...

If you edited the script in Windows, and ftp'd it to the empeg, there could be miscellaneous carriage returns in the file that are causing the preinit to barf. Make sure that when you ftp the file to the empeg, you set the mode to ascii. It should translate things appropriately. Just in case, you could get a shell on the empeg, mount the drive rw, and try this:

sh-2.03# cat > /etc/preinit.d/M01launcher
#!/bin/sh
echo Starting launcher...
/usr/apps/launcher
CTRL-D
sh-2.03#

Remount, and reboot.



Posted by: oliver

Re: preinit v4 and launcher problems? - 07/08/2002 08:29

Ok, i just typed that command, and i don't see any extra returns. I used the command line edit program to edit this file on my windows machine. Here is what i typed:

empeg:/etc/preinit.d# rw
empeg:/etc/preinit.d# cat M01launcher
#!/bin/sh
echo "Starting launcher..."
/usr/apps/launcher
empeg:/etc/preinit.d# ro

This looked good to me, anything else that might be wrong?
Posted by: suomi35

Re: preinit v4 and launcher problems? - 07/08/2002 09:04

I have been using the preinit script to launch things for awhile now and I recall running into a similar problem.

My hypothesis was that partitions outside of root get brought up after preinit is executed and therefore any calls it makes to apps living on other partitions won't be sucessful. I moved all the apps I wanted preinit to exec into /bin and it worked perfectly.
Posted by: jheathco

Re: preinit v4 and launcher problems? - 07/08/2002 11:18

To bad it can't wait for a mount
Posted by: oliver

Re: preinit v4 and launcher problems? - 07/08/2002 12:05

Ok, i just found ae again. I then saw a blank line at the bottom of the screen. Deleted it. And now launcher loads at startup. But, i still get the memory errors.

kftpd: listening on port 21
player.cpp : 385:empeg-car 2.00-beta13 2002/07/24.
Starting launcher...
hijack(9): memory violation at pc=0x020045a0, lr=0x02004548 (bad address=0x464c4
587, code 2)
pc : [<020045a0>] lr : [<02004548>]
sp : bffffe80 ip : bffffea0 fp : bffffe9c
r10: 020006c8 r9 : 00000000 r8 : 0202f010
r7 : 0203ff30 r6 : 464c457f r5 : 0203ff20 r4 : 00000010
r3 : 00001049 r2 : 00000010 r1 : 00001048 r0 : 464c457f
Flags: nZCv IRQs on FIQs on Mode USER_32 Segment user
Control: C0F8517D Table: C0F8517D DAC: 00000015
Function entered at [<02004578>] from [<02004548>]
r7 = 00000000 r6 = 020000C0 r5 = 0203FF20 r4 = 464C457F
Function entered at [<020044a0>] from [<020009c0>]
r5 = BFFFFF74 r4 = 00000001
Function entered at [<020006c8>] from [<02000b64>]
Function entered at [<02000a88>] from [<02000104>]
r10 = 00000000 r8 = 00000000 r7 = 00000000 r6 = 00000000
r5 = 00000000 r4 = 00000000
Prolux 4 empeg car - 2.1434 Jul 24 2002
Vcb: 0x4086d000

I had a hell of a time finding out how to save the file in ae. The only thing i could find was ctrl+x ctrl+c, but after guessing key strokes, i found ctrl+x+w would save the file.

So now i guess i'm in the same boat as you are, with these errors, but launcher still working.
Posted by: oliver

Re: preinit v4 and launcher problems? - 07/08/2002 16:52

ok, after getting everything working on my deck today. I tarred up everything (preinit v4, apps, preinit.d scripts) to make a backup for the next time i run an .upgrade. I also did this to easily put these files on the 6 or 8 decks that i keep up. After un-tarring the files, and rebooting. I noticed that the second player everything works, but it doesn't give the memory violation error. Could this mean that my player has bad ram? I don't understand why this would happen on some players and not all? Thanks in advance!
Posted by: genixia

Re: preinit v4 and launcher problems? - 07/08/2002 21:32

Do you have reservecache set in config.ini?
Posted by: oliver

Re: preinit v4 and launcher problems? - 07/08/2002 22:21

I don't see it set in my config.ini
Here is my config file
[tuner]

region=us
[controls]
stalk_side=none
[hush]
hushpercent=50
[display]
visual_names=1
caching=0
[volumecap]
enabled=1
[kenwood]
disabled=0
[ramp]
disabled=0
[menu]
quit=0
sort_playlist=1
[Options]
Name=UzI-O
[User Info]
[email protected]
Phone=555-555-5555
Name=Oliver Hine
[Network]
Gateway=0.0.0.0
Netmask=0.0.0.0
IPAddress=0.0.0.0
DHCP=1
[sense]
muteaction=0
mute=-1
[power]
off_timeout=20000
[aux]
source=
title=
artist=
[synchronise]
seq_num=58
[wendy]
flag_amount=0
[custom]
wendy=
[searches]
amount=0
[VisualFavourites_AM]
count=0
[VisualFavourites_AUX]
count=0
[VisualFavourites_DSP]
count=0
[VisualFavourites_FM]
count=0
[launcher]
approot=/usr/apps/
item=Games.Pacman,empacman
item=Games.Sokoban,empsoko,l
item=Games.Tetris,emptris
item=Games.Emptriv,/usr/scripts/startEmptriv
item=Utils.File Viewer,viewer
item=Utils.telnetd.Start,/etc/preinit.d/N02telnetd,start
item=Utils.telnetd.Stop,/etc/preinit.d/N02telnetd,stop
item=Utils.telnetd.Restart,/etc/preinit.d/N02telnetd,restart
Posted by: genixia

Re: preinit v4 and launcher problems? - 08/08/2002 05:27

Try adding the following and see if you still get the memory errors:

[Startup]
reservecache=2
Posted by: oliver

Re: preinit v4 and launcher problems? - 08/08/2002 11:41

Hi Genixia,
I added that line at the top of my ini, and it, i guess, fixed the problem with the memory errors. My next questions is
What exactly did this reservecache=2 change on my player?

And if all of our empegs are pretty much the same, why would only a few people see this problem, and most people don't?

Thanks for your help.
Posted by: genixia

Re: preinit v4 and launcher problems? - 08/08/2002 12:27

As I understand it, It tells the player how much of the available RAM to *not* grab for itself, By default, the player allocates as much memory as it can for buffering music.
Posted by: Warp10

Re: preinit v4 and launcher problems? - 24/09/2002 15:07

I've got the same problem canuckInLA described: The memory violation only appears if there are scripts in the preinit.d folder. Anything new about this? Should I ignore the violation?

Cheers,
Thorsten
Posted by: wfaulk

Re: preinit v4 and launcher problems? - 24/09/2002 20:00

Honestly, I'm at a loss here. I can't imagine why the program would core dump. Maybe it's my compiler. Anyone else want to try compiling it? The source code's available.
Posted by: jaharkes

Re: preinit v4 and launcher problems? - 25/09/2002 08:13

I've not compiled it yet, but I noticed that you are passing /bin/sh %s to system(3). But system itself is already a wrapper around exec that adds /bin/sh -c

So you end up forking off, execing a shell that runs a shell, that possibly runs a shell as well (because of the missing -c?), that runs the script. At least as far I can tell you at least want to drop the /bin/sh there and preferable switch to using

execv("/bin/sh", {"/bin/sh", "-c", "/etc/preinit.d/%s", NULL});
Posted by: jaharkes

Re: preinit v4 and launcher problems? - 25/09/2002 08:23

Ohh, it might even be simpler than that. Just ran it through valgrind, this is without any /etc/preinit.d scripts (and ofcourse not on the player itself).

==13932== Invalid write of size 4
==13932== at 0x8048D39: main (empeg-preinit.c:226)
==13932== by 0x4025D0BF: (within /lib/libc-2.2.5.so)
==13932== by 0x80486F1: alarm:GLIBC_2.0 (in /home/jaharkes/empeg/gps/empeg-preinit.v4/empeg-preinit.test)
==13932== Address 0x42AE2060 is 0 bytes after a block of size 4 alloc'd
==13932== at 0x4004328B: malloc (vg_clientfuncs.c:100)
==13932== by 0x8048CFD: main (empeg-preinit.c:216)
==13932== by 0x4025D0BF: (within /lib/libc-2.2.5.so)

which points at this

empeg-preinit.c:216
- mounttime = malloc(sizeof(struct filelist *));
+ mounttime = malloc(sizeof(struct filelist));
Posted by: peter

Re: preinit v4 and launcher problems? - 25/09/2002 08:36

Just ran it through valgrind

Valgrind rules.

Peter
Posted by: jaharkes

Re: preinit v4 and launcher problems? - 25/09/2002 09:14

Ok, this time I ran it with an /etc/preinit.d directory and a couple of scripts. Found some double free's and some issues in the part where system() is called, some error paths could either leak or double free. With the deep nesting this code is quite hard to follow.

Patch against preinit.v3 is attached.
Posted by: wfaulk

Re: preinit v4 and launcher problems? - 25/09/2002 10:34

Ooh! There you have it. I've been outed as a bad programmer.

Seriously, though, I thought I'd triple-checked all that stuff. I'll go back and do it again. Didn't know about valgrind. I'll have to check it out.

And no more cracks about my indentation style.
Posted by: jaharkes

Re: preinit v4 and launcher problems? - 25/09/2002 10:57

It wasn't me, it was all valgrind's fault. btw. Looking at the stuff I replaced around the call to system, the old code did the alloc/free right, so the segfaults must have come from either the bad malloc or one of the double free's.

And as far as indentation is concerned, at least you're not following the fsf coding style and as an additional ++ you are using vi
Posted by: Warp10

Re: preinit v4 and launcher problems? - 27/09/2002 08:15

Has anyone tested if the patch fixed the memory vioaltion errors?

Uuh, that was post # 12000 plus ONE in the programming forum... and... I'm now a 'journeyman' -yeah!
Posted by: Daria

Re: preinit v4 and launcher problems? - 27/09/2002 12:25

Has anyone tested if the patch fixed the memory vioaltion errors?

yup
Posted by: Warp10

Re: preinit v4 and launcher problems? - 27/09/2002 17:14

Mmhhh ;-))) would you .... please.... attach a compiled version with the patch? I'm an absolute beginner concerning compiling...
Posted by: Daria

Re: preinit v4 and launcher problems? - 27/09/2002 17:34

Enjoy.
Posted by: Warp10

Re: preinit v4 and launcher problems? - 27/09/2002 17:49

Do you mean enjoy compiling or did you forget the attachment?
Posted by: Daria

Re: preinit v4 and launcher problems? - 27/09/2002 18:15

This time for sure
Posted by: Warp10

Re: preinit v4 and launcher problems? - 27/09/2002 18:39

What did I do???
My player only says "Waiting..." and "0:00" in the lower right...
I replaced the file hijack in /bin with the file you attached and changed to 755. What's going on? Help!!!
Thanks.
Posted by: Daria

Re: preinit v4 and launcher problems? - 27/09/2002 18:47

Do you have scripts in /etc/preinit.d?
Posted by: tfabris

Re: preinit v4 and launcher problems? - 27/09/2002 18:51

My player only says "Waiting..." and "0:00" in the lower right...

Probably has nothing to do with your init.

Check out this FAQ Entry.
Posted by: Warp10

Re: preinit v4 and launcher problems? - 27/09/2002 18:51

The M50gpsapp script. Nothing else.
I think the player goes into aux mode after booting.
Why is the new file so small compared to the old one?
Posted by: Warp10

Re: preinit v4 and launcher problems? - 27/09/2002 18:57

Simultaneous posting...
Ok, it was the aux... pooh, shock...
No idea why it switched over, I've never set the source to aux.
There's no memory violation anymore! Thanks alot.
Posted by: wfaulk

Re: preinit v4 and launcher problems? - 27/09/2002 19:01

The old one is statically linked for safety. Doesn't seem to make much of a difference in real life, though. I'll see if I can get these changes incorporated into the real source.

And, jaharkes, the reason I called /bin/sh from the system() call is because it was failing to work for me without doing that before, for some reason. I assumed it was the same reason I couldn't get a shell script to run as an init in the first place, which I couldn't figure out, so I ignored it here, too, but I didn't want to make people compile programs for startup purposes, so I explicitly called upon /bin/sh.
Posted by: jaharkes

Re: preinit v4 and launcher problems? - 27/09/2002 19:29

But /bin/sh is as far as I know only available on the developer image, so anyone with a regular image can install hijack, and upload preinit, but then nothing will work.

btw. I straced the difference between sh -c and sh and it looks like sh foo will fail when foo is not a shell script, while sh -c foo will actually exec foo when it is a binary, so sh -c sh foo should start sh, which exec's sh, which then parses the contents of foo. So the memory footprint isn't as bad as I expected initially.
Posted by: wfaulk

Re: preinit v4 and launcher problems? - 27/09/2002 19:32

Maybe the lack of /sbin/sh was the initial problem. Hadn't even considered that. I got lost in a series of odd weirdnesses. Preinit was supposed to be a quick hack. Didn't turn out that way.

Do I have your permission to use your changes to fold back into my release? I've got some other semi-released code that I should get around to releasing, too.
Posted by: jaharkes

Re: preinit v4 and launcher problems? - 27/09/2002 19:32

You've got the gps connected to the serial port, and it is set to output nmea? I guess you didn't run hack_init on the player or you are running on AC, and as such the player isn't started with -s- and is actually trying to interpret the gps data as if they were commands coming in over the serial port.

Just a hunch
Posted by: jaharkes

Re: preinit v4 and launcher problems? - 27/09/2002 19:36

Ofcourse, especially the ones that fix the couple of allocation problems that valgrind found.
Posted by: Warp10

Re: preinit v4 and launcher problems? - 28/09/2002 04:24

Do you refer to my post in the 'gpsapp - less talk more action' thread? I've run hack_init and I use gps only in the car.
My player switched to aux after uploading the patched preinit. No gps connected at that time...