postfix-pipe complains: no such file or directory

2008-09-30 Thread Jordi Moles Blanco

Hi everyone,

i was wondering if someone has experienced this problem i've been having 
for 2 weeks now.


I'm running Freebsd 7.0 and postfix-2.5.1.

The thing is that i've set up a filter written in C using postfix's 
pipe feature. The filter works great most of the times but every 
2-3 days mainly depending on the amount of load... FreeBSD hangs 
completely(or almost completely) and leaves this message behind:



pipe[44634]: fatal: pipe_command: execvp 
/usr/local/etc/postfix/quota_postfix: No such file or directory.

*

This file is never touched, i mean, it's still there even when the 
system says it can't find the file.
I've tried to change permissions of the file, just in case. Right now 
the owner is root:wheel, but i've tried postfix, also filter, and so on.


in the master.cf, i've got this:


# quota_postfix
quota_postfix  unix-   n   n   -   20  pipe
flags=R user=filter argv=/usr/local/etc/postfix/quota_postfix 
localhost 10028 ${sender} ${recipient} ${domain}



has anyone experienced that? it's a very strange thing that only gets 
fixed when you restart postfix. Sometimes i even have to reboot the machine.
This started happening some weeks after i upgraded from 6.3 to 7.0, i 
had had this script working for over a year without any problem at all.


i would be very  pleased if someone can throw some light on this issue.

Thanks in advance

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: semget: no space left on freebsd 6.2

2008-09-24 Thread Jordi Moles Blanco

hi,

that solved the problem. Thanks again.

En/na Artis Caune ha escrit:

On Tue, Sep 23, 2008 at 10:26 AM, Jordi Moles Blanco [EMAIL PROTECTED] wrote:
  

Also try adding this options on FreeBSD kernel config:
options SEMMNI=20
options SEMMNS=120

And set the kern.maxfiles sysctl option higher than 1000.

*

it didn't work either.



Hi,

you don't have to recompile the kernel to change those, just add them
in /boot/loader.conf:
kern.ipc.semmni=256
kern.ipc.semmns=512
kern.ipc.semmnu=256

You should also add these lines to /etc/sysctl.conf:
kern.ipc.shmmax=536870912
and/or also:
kern.ipc.semmap=256
kern.ipc.shm_use_phys=1
kern.ipc.shmall=131072
depending on how much memory you have and how mush shared memory modules need.





  


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


semget: no space left on freebsd 6.2

2008-09-23 Thread Jordi Moles Blanco

hello everyone,

i'm having some trouble with a freebsd 6.2 box and apache-2.0.59.  When 
i try to install some apache_mods, i get this:


For example with mod_cband:

*
apache2_mod_cband: cannot create shared memory segment for remote hosts
*

when i debug this, i get to the point where kernel says:


semget: No space left on device


It doesn't happen with all apache2_mods, but with a few, for example 
mod_cband and mod_tsunami.


i've googled a lot and found some people with the same problem but with 
apache 1.3.x. Their fix doesn't work in my box. They have tried this:


*

ipcs -s | grep nobody | perl -e 'while (STDIN) {
@a=split(/\s+/); print `ipcrm sem $a[1]`}'

*

but it doesn't work for me.
i also found this:

**

Also try adding this options on FreeBSD kernel config:
options SEMMNI=20
options SEMMNS=120

And set the kern.maxfiles sysctl option higher than 1000.

*

it didn't work either.

do you have any idea where the problem is? Thanks.


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: semget: no space left on freebsd 6.2

2008-09-23 Thread Jordi Moles Blanco

hi,

thanks a lot for the info.

i'll give it a try and report back.


En/na Artis Caune ha escrit:

On Tue, Sep 23, 2008 at 10:26 AM, Jordi Moles Blanco [EMAIL PROTECTED] wrote:
  

Also try adding this options on FreeBSD kernel config:
options SEMMNI=20
options SEMMNS=120

And set the kern.maxfiles sysctl option higher than 1000.

*

it didn't work either.



Hi,

you don't have to recompile the kernel to change those, just add them
in /boot/loader.conf:
kern.ipc.semmni=256
kern.ipc.semmns=512
kern.ipc.semmnu=256

You should also add these lines to /etc/sysctl.conf:
kern.ipc.shmmax=536870912
and/or also:
kern.ipc.semmap=256
kern.ipc.shm_use_phys=1
kern.ipc.shmall=131072
depending on how much memory you have and how mush shared memory modules need.





  


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


error allocating memory with realloc(). how can i increase max_allowed in the system?

2008-08-12 Thread Jordi Moles Blanco

Hi,

i'm running a FreeBSD 7.0 amd64 machine and struggling with some C code 
i'm writing.


I've had some trouble with this home-made script as it keeps crashing 
while launching a realloc() call.


I narrowed down the problem and here i'm sending you a short example of 
code that crashes:


*
#include stdio.h
#include stdlib.h

int main()
{

   int midataula;

   midataula = 3000;

   char *missatge = (char *)malloc(midataula * sizeof(char));

   missatge[0]='h';
   missatge[1]='o';
   missatge[2]='l';
   missatge[3]='a';

   printf(\n\ntaula1: %s,missatge);

   int voltes;
   voltes = 0;

   while(voltes4)
   {
   midataula = midataula+500;
   realloc(missatge, midataula * sizeof(char));
   voltes++;
   }


   printf(\n\ntaula2: %s,missatge);
}
*


this is a full working you can compile on your machine.

Like this... i get Segmentation fault (core dumped)

but if instead of while(voltes4) i use while(voltes3)

the script works fine with this output:

**
taula1: hola

taula2: hola
**

so... i guess there must be a limit in the system somewhere.

I've tried to reset all variables that i've seen in the sysctl -a list 
refering to malloc, memory, mem, and so on... but so far i haven't fixed 
the problem.


i'm running this script as root and in the /etc/login.conf file there's 
only the default group with the unlimited values.

A part from that, if i perform a limit call, i get this:

*

# limit
cputime  unlimited
filesize unlimited
datasize 33554432 kbytes
stacksize524288 kbytes
coredumpsize unlimited
memoryuseunlimited
vmemoryuse   unlimited
descriptors  45000
memorylocked unlimited
maxproc  22500
sbsize   unlimited

*

i've tried to resize datasize and stacksize, but the system won't let me 
do so.


any idea how to solve this?

thanks.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: error allocating memory with realloc(). how can i increase max_allowed in the system? [solved]

2008-08-12 Thread Jordi Moles Blanco

Hello,

thank you very much for your time and help, i had completely 
misunderstood how realloc() works.


i though i was able to write some C code but now i feel a complete 
newbie, hehehe.


anyway... that made everything clear to me and now my script is working 
like a charm.


thanks for everything

En/na Giorgos Keramidas ha escrit:

On Tue, 12 Aug 2008 17:02:43 +0200, Jordi Moles Blanco [EMAIL PROTECTED] 
wrote:
  

Hi,

i'm running a FreeBSD 7.0 amd64 machine and struggling with some C
code i'm writing.

I've had some trouble with this home-made script as it keeps crashing
while launching a realloc() call.

I narrowed down the problem and here i'm sending you a short example of
code that crashes:

*
#include stdio.h
#include stdlib.h

int main()
{

   int midataula;

   midataula = 3000;

   char *missatge = (char *)malloc(midataula * sizeof(char));

   missatge[0]='h';
   missatge[1]='o';
   missatge[2]='l';
   missatge[3]='a';

   printf(\n\ntaula1: %s,missatge);

   int voltes;
   voltes = 0;

   while(voltes4)
   {
   midataula = midataula+500;
   realloc(missatge, midataula * sizeof(char));
   voltes++;
   }



There's your problem.  realloc() works fine, but it *returns* the new
pointer; it does _not_ modify missatge in place.

The program should work fine if you use size_t for midataula (it is the
'size' of an array, which may not necessarily fit in an 'int'), and if
you use realloc() correctly, as in:

#include stdlib.h
#include err.h

size_t midataula;
char *missatge;

/*
 * DON'T cast the result of malloc().  It may 'hide' the bug of
 * a missing stdlib.h include, and cause troubles when
 * malloc() is implicitly defined by the compiler as:
 *
 *int malloc(...);
 *
 * On a 64-bit machine converting a 64-bit pointer to `int' will
 * lose the high-order 32 bits of the address, and you will try
 * to access unexpected memory areas.
 */
midataula = 3000;
missatge = malloc(midataula * sizeof(*missatge));
if (missatge == NULL)
err(1, malloc);

Then when you use realloc() keep both midataula and missatge in
temporary copies until you are sure that realloc() worked:

while (voltes  4) {
char *tmp;
size_t newsize;

newsize = midataula + 500;
tmp = realloc(missatge, newsize * sizeof(*missatge));
if (tmp == NULL)
err(1, realloc);

/*
 * Now that you know the resize has succeeded, update
 * midataula and missatge.  realloc() is allowed to
 * relocate missatge.  See the following note in its
 * manpage:
 *
 *   Note that realloc() and reallocf() may move the
 *   memory allocation, resulting in a different return
 *   value than ptr.
 */
midataula = newsize;
missatge = tmp;
}

Right now you are calling realloc() as:

realloc(missatge, newsize * sizeof(*missatge));

and throwing away the resulting pointer.  The first time that realloc()
discovers that the `resized' vector cannot fit in its original location,
it relocates the array, and returns the new location.  You throw away
that location and your next iteration through the loop tries to access
an invalid (already freed) memory region.

That's what causes your segmentation fault.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]
  


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: problems with a C script, exiting with signal 10

2008-08-11 Thread Jordi Moles Blanco

Hi,

i've been trying to debug what you suggested, but no luck so far :(

The thing is that i checked out all the calls to arrays, space handling 
and so on, and i couldn't find anything wrong.


After that, i ended up trying the hard way, which is to keep a file 
/tmp/debug.log where the script writes everything that it does. So... 
the problem was that even in those cases when postfix logged a signal 
10 error, the logs showed that the C script got to the end of the file, 
it executed every single line, it doesn't get stuck manipulating arrays 
or anything like that.



any idea?

Thanks.



En/na Jordi Moles Blanco ha escrit:

Hi,

thanks for the reply, i will have a close look at what you suggested. 
The thing is that, yes, i work with arrays, pointers, mallocs and so 
on. I'll try to make sure everything is initiliazed properly before 
being used.


Thanks for the advice.




En/na Patrick Mahan ha escrit:



Jordi Moles Blanco presented these words - circa 8/7/08 3:13 AM-

Hi,

I've got this home-made script, written in C, on a  Freebsd 7.0 
server with different versions of postfix: 2.3,2,4 and 2.5


The problem is that, while most of the time it works like a charm, 
sometimes it crashes and bounces the message. It's not really a big 
deal, cause the sender gets notified that their mail wasn't 
delivered and hopefully, they will resend it. However, the problem 
is that I've tried to debug my script but found nothing wrong at 
all, cause it only fails from time to time, let's say... once for 
each 2000 messages that postfix receives, and it appears to do so in 
a random way.


As i said... postfix can fail to deliver a message to one particular 
mailbox, but if then you resend the very same message to the very 
same mailbox, it will be delivered.


The error is reported in both maillog and messages, like this:


**/var/log/maillog
Aug  7 01:55:19 mail01 postfix/pipe[27534]: 3E1A0143709: 
to=EMAIL_ACCOUNT, relay=quota_postfix, delay=0.23, 
delays=0.11/0/0/0.11, dsn=5.3.0, status=bounced (Command died with 
signal 10: /usr/local/etc/postfix/quota_postfix)



*/var/log/messages***
Aug  7 01:55:19 mail01 kernel: pid 29535 (quota_postfix), uid 125: 
exited on signal 10




Well signal 10 is SIGBUS which is indicative of (generally) a bad 
address,
non-aligned memory address (on platforms it matters) or a hardware 
error.

I would look for places you are dereferencing a pointer without perhaps
first validating it.

Given that it rarely occurs, I might suspect that you are allocating 
some

memory, but failing to completely initialize (malloc() doesn't zero out
memory) it or assuming it is already initialize.

Good luck,

Patrick


Here you have some extra information about the script itself and the 
master.cf



*/usr/local/etc/postfix/quota_postfix***

# ls -la /usr/local/etc/postfix/quota_postfix
-rwsr-xr-x  1 postfix  postfix  20048 Aug  4 10:18 
/usr/local/etc/postfix/quota_postfix


It's got de suid flag cause it performs a du command and other 
file operations which need permissions, although i've tried with 
other groups of permissions and it eventually crashes anyway with 
signal 10


**master.cf*

.

# spamfilter
spamfilter  unix-   n   n   -   20  pipe
flags=R user=filter argv=/home/antispam.pl localhost:10027 
antispam ${sender} ${recipient} /usr/local/bin/spamc


# from spamfilter to smtpd:10026
localhost:10027 inetn   -   n   -   100   
smtpd -o content_filter=quota_postfix



# quota_postfix
quota_postfix  unix-   n   n   -   20  pipe
flags=R user=filter argv=/usr/local/etc/postfix/quota_postfix 
localhost 10028 ${sender} ${recipient} ${domain}


# from quota_postfix to smtpd:10028
localhost:10028 inetn   -   n   -   100   
smtpd -o content_filter=




So far, any program which crashed would leave a .core file in 
/usr/crash, but this one is not doing the same, so... i can't 
actually debug from the core file either.
Sysctl in my FreeBSD server is ok, but i guess that postfix, somehow 
is preventing this filter from generating a core file. Is that 
possible? Or am i completely wrong?


How could I, at least, generate the .core file?

Thanks.


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to 
[EMAIL PROTECTED]





___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to 
[EMAIL PROTECTED]


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: problems with a C script, exiting with signal 10

2008-08-08 Thread Jordi Moles Blanco

Hi,

thanks for the reply, i will have a close look at what you suggested. 
The thing is that, yes, i work with arrays, pointers, mallocs and so on. 
I'll try to make sure everything is initiliazed properly before being used.


Thanks for the advice.




En/na Patrick Mahan ha escrit:



Jordi Moles Blanco presented these words - circa 8/7/08 3:13 AM-

Hi,

I've got this home-made script, written in C, on a  Freebsd 7.0 
server with different versions of postfix: 2.3,2,4 and 2.5


The problem is that, while most of the time it works like a charm, 
sometimes it crashes and bounces the message. It's not really a big 
deal, cause the sender gets notified that their mail wasn't delivered 
and hopefully, they will resend it. However, the problem is that I've 
tried to debug my script but found nothing wrong at all, cause it 
only fails from time to time, let's say... once for each 2000 
messages that postfix receives, and it appears to do so in a random way.


As i said... postfix can fail to deliver a message to one particular 
mailbox, but if then you resend the very same message to the very 
same mailbox, it will be delivered.


The error is reported in both maillog and messages, like this:


**/var/log/maillog
Aug  7 01:55:19 mail01 postfix/pipe[27534]: 3E1A0143709: 
to=EMAIL_ACCOUNT, relay=quota_postfix, delay=0.23, 
delays=0.11/0/0/0.11, dsn=5.3.0, status=bounced (Command died with 
signal 10: /usr/local/etc/postfix/quota_postfix)



*/var/log/messages***
Aug  7 01:55:19 mail01 kernel: pid 29535 (quota_postfix), uid 125: 
exited on signal 10




Well signal 10 is SIGBUS which is indicative of (generally) a bad 
address,

non-aligned memory address (on platforms it matters) or a hardware error.
I would look for places you are dereferencing a pointer without perhaps
first validating it.

Given that it rarely occurs, I might suspect that you are allocating some
memory, but failing to completely initialize (malloc() doesn't zero out
memory) it or assuming it is already initialize.

Good luck,

Patrick


Here you have some extra information about the script itself and the 
master.cf



*/usr/local/etc/postfix/quota_postfix***

# ls -la /usr/local/etc/postfix/quota_postfix
-rwsr-xr-x  1 postfix  postfix  20048 Aug  4 10:18 
/usr/local/etc/postfix/quota_postfix


It's got de suid flag cause it performs a du command and other file 
operations which need permissions, although i've tried with other 
groups of permissions and it eventually crashes anyway with signal 10


**master.cf*

.

# spamfilter
spamfilter  unix-   n   n   -   20  pipe
flags=R user=filter argv=/home/antispam.pl localhost:10027 
antispam ${sender} ${recipient} /usr/local/bin/spamc


# from spamfilter to smtpd:10026
localhost:10027 inetn   -   n   -   100   
smtpd -o content_filter=quota_postfix



# quota_postfix
quota_postfix  unix-   n   n   -   20  pipe
flags=R user=filter argv=/usr/local/etc/postfix/quota_postfix 
localhost 10028 ${sender} ${recipient} ${domain}


# from quota_postfix to smtpd:10028
localhost:10028 inetn   -   n   -   100   
smtpd -o content_filter=




So far, any program which crashed would leave a .core file in 
/usr/crash, but this one is not doing the same, so... i can't 
actually debug from the core file either.
Sysctl in my FreeBSD server is ok, but i guess that postfix, somehow 
is preventing this filter from generating a core file. Is that 
possible? Or am i completely wrong?


How could I, at least, generate the .core file?

Thanks.


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to 
[EMAIL PROTECTED]





___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


problems with a C script, exiting with signal 10

2008-08-07 Thread Jordi Moles Blanco

Hi,

I've got this home-made script, written in C, on a  Freebsd 7.0 server 
with different versions of postfix: 2.3,2,4 and 2.5


The problem is that, while most of the time it works like a charm, 
sometimes it crashes and bounces the message. It's not really a big 
deal, cause the sender gets notified that their mail wasn't delivered 
and hopefully, they will resend it. However, the problem is that I've 
tried to debug my script but found nothing wrong at all, cause it only 
fails from time to time, let's say... once for each 2000 messages that 
postfix receives, and it appears to do so in a random way.


As i said... postfix can fail to deliver a message to one particular 
mailbox, but if then you resend the very same message to the very same 
mailbox, it will be delivered.


The error is reported in both maillog and messages, like this:


**/var/log/maillog
Aug  7 01:55:19 mail01 postfix/pipe[27534]: 3E1A0143709: 
to=EMAIL_ACCOUNT, relay=quota_postfix, delay=0.23, 
delays=0.11/0/0/0.11, dsn=5.3.0, status=bounced (Command died with 
signal 10: /usr/local/etc/postfix/quota_postfix)



*/var/log/messages***
Aug  7 01:55:19 mail01 kernel: pid 29535 (quota_postfix), uid 125: 
exited on signal 10



Here you have some extra information about the script itself and the 
master.cf



*/usr/local/etc/postfix/quota_postfix***

# ls -la /usr/local/etc/postfix/quota_postfix
-rwsr-xr-x  1 postfix  postfix  20048 Aug  4 10:18 
/usr/local/etc/postfix/quota_postfix


It's got de suid flag cause it performs a du command and other file 
operations which need permissions, although i've tried with other groups 
of permissions and it eventually crashes anyway with signal 10


**master.cf*

.

# spamfilter
spamfilter  unix-   n   n   -   20  pipe
flags=R user=filter argv=/home/antispam.pl localhost:10027 antispam 
${sender} ${recipient} /usr/local/bin/spamc


# from spamfilter to smtpd:10026
localhost:10027 inetn   -   n   -   100   smtpd 
-o content_filter=quota_postfix



# quota_postfix
quota_postfix  unix-   n   n   -   20  pipe
flags=R user=filter argv=/usr/local/etc/postfix/quota_postfix 
localhost 10028 ${sender} ${recipient} ${domain}


# from quota_postfix to smtpd:10028
localhost:10028 inetn   -   n   -   100   smtpd 
-o content_filter=




So far, any program which crashed would leave a .core file in 
/usr/crash, but this one is not doing the same, so... i can't actually 
debug from the core file either.
Sysctl in my FreeBSD server is ok, but i guess that postfix, somehow is 
preventing this filter from generating a core file. Is that possible? Or 
am i completely wrong?


How could I, at least, generate the .core file?

Thanks.


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]