How to apply a patch

Missing Ghost

Senior member
Oct 31, 2005
254
0
76
Hi I'm having some problems with samba on openbsd. It's a memory leak.
top gives me this:
Memory: Real: 23M/54M act/tot Free: 2656K Swap: 86M/128M used/tot
Normally, this machine uses only 35-40MB memory, and no swap at all.
Thanks to some help from somebody, I have been able to conclude that this is due to a massive memory leak in samba while accessing my music library that has around 1500 files. I googled and found
this

It shows me a patch on a link on this page.
The patch is in a format that I don't know, with - for things to remove and + for things to add. How am I supposed to apply this exactly?

Also, anybody would have another idea about where is the problem coming from?
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
The patch is in pretty much the standard format for all patches ;) You apply it using the patch(1) command.

First of all, do you have the userland source in /usr/src? If you've got the cds, it should be on there or you can also get it from wherever you may have downloaded the base packages if you did an online install. Then you'd put the patch in /usr/src and use patch(1) to apply it. Then it looks like you'd have to rebuild libc but I can't tell you exactly what to rebuild, as those instructions are usually included with official patches.

Given that this is a 2 year old netbsd patch, I'd be a little hesitant to apply it to openbsd without official endorsement though :confused:
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
I don't know, I'm somewhat of an OpenBSD beginner and I don't think I'd ever apply a patch that wasn't directly from the project unless I had spent time debugging and fixing something myself (one way or the other, someone's got to be sure that it's going to work).

Barring that, the first thing I'd try to do is find out if there's some work around. The emails I read seemed to imply that the leak only happened in certain situations. If that wasn't possible, I might try hollering on misc@, bumping that thread. Provide a very thorough description of your situation, and a dmesg never hurts, and see if you can get one of the developers interested enough to dive into the code and fix it properly. A Marc Balmer is apparently the maintainer of the samba port. Maybe try searching ports@ for relevant threads.

Last resort? Find another platform to run samba on? But most importantly, I wouldn't take instructions from me, I'd wait for n0cmonkey to show up 'cause he's the local openbsd expert :p
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
I'd try making less full directories. Barring that, I'd give the patch a try. Download and extract the source (for the version you're using!) either through AnonCVS or from an FTP mirror (AnonCVS will give you -stable, which is good). After the source has been downloaded, following the directions linked to above you'd probably apply the patch with the command: cd /usr/src && patch -p0 < /PATH/TO/PATCH

After that, you'll probably have to rebuild a bunch of stuff. If you download -stable (and you should), you could rebuild the system from source. It's pretty easy, although it could take a while on a slow machine (a little over 24 hours on a sparcstation 10 with a 36mhz proc and 32mb of ram, 8 hour or so on decent i386 based machines IIRC).

If the patch works for you, definitely let the mailing list know. It hasn't been integrated yet, but it's possible in the future (the source tree was just unlocked).
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Any idea if that's the type of thing that would be put in -stable (and errata?) or would one have to wait another 6 months if not wanting to run -current?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: kamper
Any idea if that's the type of thing that would be put in -stable (and errata?) or would one have to wait another 6 months if not wanting to run -current?

I'm guessing it's too much of a change for -stable. Might be "easily" backported if you don't mind deviating from the official sources.

Use snapshots. -current is too complicated, -release is too old, and -stable just isn't enough. ;)
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
-release + selected errata is enough for me :)

I just listened to an interview with Marco Peereboom on bsdtalk and he said he had web servers still running 3.2 or 3.3 or something like that :shocked:
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: kamper
-release + selected errata is enough for me :)

I just listened to an interview with Marco Peereboom on bsdtalk and he said he had web servers still running 3.2 or 3.3 or something like that :shocked:

Yeah, it''s crazy. Listen to the Henning one too, it's pretty good. Matt Dillon's was awesome, and Scott Long's was kind of interesting too.

Just adding those patches isn't enough for me. Too many changes to -stable don't make it to patches...
 

smashp

Platinum Member
Aug 30, 2003
2,443
0
0
How do you apply a patch with openBSD?

rebuild the box

especially if it is a really old build.