Hi,

I've attached a diff against the current CVS version. Only
modules/owlib/src/c/ow_net.c needs to be changed. (not sure this is
correct input for patch, please give me a commandline for cvs diff if
you need another format...).

Regards,
Wim.

Paul Alfille wrote:
> I'd love a patch!
> 
> On 4/10/06, *Wim Heirman* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
> 
>     Hi,
> 
>     > Are you using a standard i386 with glib?  I'm having trouble
>     seeing what
>     > has changed to make a code change needed.
> 
>     Yes, it's a Plain Old Dell i686 running a stock Fedora Core 5 with
>     kernel 2.6.16 and glibc 2.4. It only started going wrong when I upgraded
>     my kernel to 2.6.16, do you have that same kernel version too?
> 
>     > The "embedded functions" were mainly a convenience. Without them,
>     a lot
>     > of custom structures, pointer manipulation and extra functions are
>     needed.
> 
>     I've noticed that ;) Actually you only need one extra struct to pass
>     out2 and HandlerRoutine to AcceptThread through the thread creation.
>     For
>     ConnectionThread it would be worse, but it's still embedded here and it
>     works, so the problem may be only in the double embedding.
> 
>     > If it's needed, I'll do it.
> 
>     I can send a patch, just need to clean up some. Is anyone else running
>     2.6.16 already? Does it happen there too?
> 
> 
>     Regards,
>     Wim
> 
> 
>     > On 4/10/06, *Wim Heirman* <[EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>
>     > <mailto: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>> wrote:
>     >
>     >     Hi,
>     >
>     >     I updated to the latest CVS, no change. However, I started digging
>     >     around some more myself, I believe the problem is that
>     pthread_create()
>     >     doesn't like running an embedded function. When I get rid of the
>     >     embedding it seems to work again.
>     >     Anyone else has some experience/comments on this, or should I
>     just clean
>     >     this up into a patch you can apply?
>     >
>     >     Regards,
>     >     Wim.
>     >
>     >
>     >     Paul Alfille wrote:
>     >     > I've been testing (and correcting) OWFS extensively. No
>     segfaults, no
>     >     > problems with threading. Want to try a fresh pull and retest?
>     >     >
>     >     > Paul
>     >     >
>     >     > On 4/9/06, *Wim Heirman* <[EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>
>     >     <mailto: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
>     >     > <mailto: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>     <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>>> wrote:
>     >     >
>     >     >     I've grabbed some more gdb output:
>     >     >
>     >     >     (gdb) run -u --foreground -p localhost:owfs
>     >     >     <...>
>     >     >     Program received signal SIGSEGV, Segmentation fault.
>     >     >     [Switching to Thread 23919520 (LWP 23820)]
>     >     >     0x001163af in start_thread () from /lib/libpthread.so.0
>     >     >     (gdb) bt
>     >     >     #0  0x001163af in start_thread () from /lib/libpthread.so.0
>     >     >     #1  0x00ae133e in clone () from /lib/libc.so.6
>     >     >     (gdb) info
>     >     >     threads
>     >     >     * 2 Thread 23919520 (LWP 23820)  0x001163af in
>     start_thread ()
>     >     from
>     >     >     /lib/libpthread.so.0
>     >     >        1 Thread -1208199504 (LWP 23796)  0x009fb402 in
>     >     __kernel_vsyscall ()
>     >     >     (gdb) thread 1
>     >     >     [Switching to thread 1 (Thread -1208199504 (LWP
>     >     >     23796))]#0  0x009fb402 in
>     >     >     __kernel_vsyscall ()
>     >     >     (gdb) bt
>     >     >     #0  0x009fb402 in __kernel_vsyscall ()
>     >     >     #1  0x0011b7ae in __lll_mutex_lock_wait () from
>     >     /lib/libpthread.so.0
>     >     >     #2  0x0011816c in _L_mutex_lock_70 () from
>     /lib/libpthread.so.0
>     >     >     #3  0x00117fb8 in pthread_mutex_lock () from
>     /lib/libpthread.so.0
>     >     >     #4  0x00cb5e3f in ConnectionThread.6627 () at ow_net.c:314
>     >     >     #5  0x00cb5fab in ServerProcess (HandlerRoutine=0x8049a20
>     >     <Handler>,
>     >     >     Exit=0x8049020 <ow_exit>) at ow_net.c:353
>     >     >     #6  0x08049192 in main (argc=5, argv=0xbfeddce4) at
>     owserver.c:558
>     >     >
>     >     >
>     >     >     I also tried using owpython without owserver (so with
>     >     ow.init('u')),
>     >     >     this
>     >     >     works regardless of whether thread-support is compiled in.
>     >     >
>     >     >     Regards,
>     >     >     Wim
>     >     >
>     >     >
>     >     >     On Fri, 7 Apr 2006, Wim Heirman wrote:
>     >     >
>     >     >     > Hi,
>     >     >     >
>     >     >     > Apparently my new (not yet installed) owserver was still
>     >     linking
>     >     >     to the
>     >     >     > libow in /lib, not the freshly compiled one, so now at
>     least
>     >     I got the
>     >     >     > --disable-mt version working. With multithreading enabled
>     >     the problem
>     >     >     > remains however.
>     >     >     >
>     >     >     > owfs is defined as port 10123 in /etc/services.
>     >     >     >
>     >     >     > Regards,
>     >     >     > Wim
>     >     >     >
>     >     >     > Alfille, Paul H.,M.D. wrote:
>     >     >     >> Wim,
>     >     >     >>
>     >     >     >> I ran into a similar problem a little while ago, fixed by
>     >     making
>     >     >     sure that libow
>     >     >     >> and libfuse were compiled and updated.
>     >     >     >>
>     >     >     >> By the way, is "owfs" defined as a port?
>     >     >     >>
>     >     >     >> Paul
>     >     >     >>
>     >     >     >>
>     >     >     >> -----Original Message-----
>     >     >     >> From: [EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>
>     >     <mailto: [EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>>
>     >     >     <mailto:[EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>
>     >     <mailto: [EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>>> on behalf of
>     >     >     Wim Heirman
>     >     >     >> Sent: Fri 4/7/2006 5:12 AM
>     >     >     >> To: [email protected]
>     <mailto:[email protected]>
>     >     <mailto:[email protected]
>     <mailto:[email protected]>>
>     >     >     <mailto: [email protected]
>     <mailto:[email protected]>
>     >     <mailto:[email protected]
>     <mailto:[email protected]>>>
>     >     >     >> Subject: [Owfs-developers] owserver segfaulting on
>     startup
>     >     >     >>
>     >     >     >> Hello,
>     >     >     >>
>     >     >     >> Has anyone seen the following problem? When starting
>     owserver:
>     >     >     >>
>     >     >     >> root#  ./owserver -u --foreground -p localhost:owfs
>     >     >     >> Segmentation fault
>     >     >     >>
>     >     >     >> GDB traceback is included at the bottom. This is on a
>     >     Fedora Core 5
>     >     >     >> machine with kernel 2.6.16. Yesterday, with kernel
>     2.6.15,
>     >     >     owserver ran
>     >     >     >> normally. Since the segfault is in libpthread I tried
>     >     recompiling
>     >     >     owfs
>     >     >     >> with --disable-mt, but this did not change the
>     result. I'm
>     >     using
>     >     >     the CVS
>     >     >     >> version of owfs from today (2006-04-07).
>     >     >     >>
>     >     >     >> Regards,
>     >     >     >> Wim.
>     >     >     >>
>     >     >     >>
>     >     >     >> root# gdb ./owserver
>     >     >     >> GNU gdb Red Hat Linux (6.3.0.0-1.122rh)
>     >     >     >> Copyright 2004 Free Software Foundation, Inc.
>     >     >     >> GDB is free software, covered by the GNU General Public
>     >     License,
>     >     >     and you are
>     >     >     >> welcome to change it and/or distribute copies of it
>     under
>     >     certain
>     >     >     >> conditions.
>     >     >     >> Type "show copying" to see the conditions.
>     >     >     >> There is absolutely no warranty for GDB.  Type "show
>     warranty"
>     >     >     for details.
>     >     >     >> This GDB was configured as
>     "i386-redhat-linux-gnu"...Using host
>     >     >     >> libthread_db library "/lib/libthread_db.so.1".
>     >     >     >>
>     >     >     >> (gdb) run -u --foreground -p localhost:owfs
>     >     >     >> Starting program:
>     >     >     >>
>     /usr/src/owfs_cvs/owfs/module/owserver/src/c/.libs/owserver -u
>     >     >     >> --foreground -p localhost:owfs
>     >     >     >> Reading symbols from shared object read from target
>     >     memory...done.
>     >     >     >> Loaded system supplied DSO at 0x9fb000
>     >     >     >> [Thread debugging using libthread_db enabled]
>     >     >     >> [New Thread -1208432976 (LWP 30428)]
>     >     >     >> [New Thread 23866272 (LWP 30431)]
>     >     >     >>
>     >     >     >> Program received signal SIGSEGV, Segmentation fault.
>     >     >     >> [Switching to Thread 23866272 (LWP 30431)]
>     >     >     >> 0x00cb33af in start_thread () from /lib/libpthread.so.0
>     >     >     >> (gdb) bt
>     >     >     >> #0  0x00cb33af in start_thread () from
>     /lib/libpthread.so.0
>     >     >     >> #1  0x00ae133e in clone () from /lib/libc.so.6
>     >     >     >> (gdb)
>     >     >     >>
>     >     >     >>
>     >     >     >>
>     >     >     >>
>     >     >     >>
>     >     >     >
>     >     >     >
>     >     >
>     >     >     --
>     >     >     ir. Wim Heirman,
>     >     >     ELIS Department, Ghent University, Belgium
>     >     >     Phone: +32-9-264.95.27
>     >     >     E-mail: [EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>
>     >     <mailto:[EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>>
>     <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>     >     <mailto:[EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>>>
>     >     >     http://www.elis.UGent.be/~wheirman/
>     >     >
>     >     >
>     >     >     -------------------------------------------------------
>     >     >     This SF.Net email is sponsored by xPML, a groundbreaking
>     >     scripting
>     >     >     language
>     >     >     that extends applications into web and mobile media. Attend
>     >     the live
>     >     >     webcast
>     >     >     and join the prime developer group breaking into this
>     new coding
>     >     >     territory!
>     >     >
>     >    
>     http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>     <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642>
>     >    
>     <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>     
> <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642>>
>     >     >     <
>     >    
>     http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>     <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642>
>     >     <
>     http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>     
> <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642>>>
>     >     >     _______________________________________________
>     >     >     Owfs-developers mailing list
>     >     >     [email protected]
>     <mailto:[email protected]>
>     >     <mailto:[email protected]
>     <mailto:[email protected]>>
>     >     >     <mailto:[email protected]
>     <mailto:[email protected]>
>     >     <mailto:[email protected]
>     <mailto:[email protected]>>>
>     >     >     https://lists.sourceforge.net/lists/listinfo/owfs-developers
>     >     >
>     >     >
>     >
>     >     --
>     >     ir. Wim Heirman,
>     >     ELIS Department, Ghent University, Belgium
>     >     Phone: +32-9-264.95.27
>     >     E-mail: [EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]> <mailto:
>     [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
>     >     http://www.elis.UGent.be/~wheirman/
>     >
>     >
>     >     -------------------------------------------------------
>     >     This SF.Net email is sponsored by xPML, a groundbreaking scripting
>     >     language
>     >     that extends applications into web and mobile media. Attend
>     the live
>     >     webcast
>     >     and join the prime developer group breaking into this new coding
>     >     territory!
>     >    
>     http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>     <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642>
>     >    
>     <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>     
> <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642>>
>     >     _______________________________________________
>     >     Owfs-developers mailing list
>     >     [email protected]
>     <mailto:[email protected]>
>     >     <mailto: [email protected]
>     <mailto:[email protected]>>
>     >     https://lists.sourceforge.net/lists/listinfo/owfs-developers
>     >
>     >
> 
>     --
>     ir. Wim Heirman,
>     ELIS Department, Ghent University, Belgium
>     Phone: +32-9-264.95.27
>     E-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
>     http://www.elis.UGent.be/~wheirman/
> 
> 
>     -------------------------------------------------------
>     This SF.Net email is sponsored by xPML, a groundbreaking scripting
>     language
>     that extends applications into web and mobile media. Attend the live
>     webcast
>     and join the prime developer group breaking into this new coding
>     territory!
>     http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>     <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642>
>     _______________________________________________
>     Owfs-developers mailing list
>     [email protected]
>     <mailto:[email protected]>
>     https://lists.sourceforge.net/lists/listinfo/owfs-developers
> 
> 

-- 
ir. Wim Heirman,
ELIS Department, Ghent University, Belgium
Phone: +32-9-264.95.27
E-mail: [EMAIL PROTECTED]
http://www.elis.UGent.be/~wheirman/
RCS file: /cvsroot/owfs/owfs/module/owlib/src/c/ow_net.c,v
retrieving revision 1.36
diff -r1.36 ow_net.c
253d252
<  Doubly embedded function.
266a266,292
> 
> void RunAccepted( int rafd, void (*HandlerRoutine)(int fd) ) {
>     if ( rafd>=0 ) {
>         HandlerRoutine( rafd ) ;
>         close( rafd ) ;
>     } else {
>         STAT_ADD1(NET_accept_errors);
>         LEVEL_CONNECT("accept() error %d [%s]\n", errno, strerror(errno));
>     }
> }
> 
> struct AcceptThread_data {
>     struct connection_out *o2;
>     void (*HandlerRoutine)(int fd);
> };
> void * AcceptThread( void * v2 ) {
>     struct AcceptThread_data * data = (struct AcceptThread_data *)v2;
>     int acceptfd = accept( data->o2->fd, NULL, NULL ) ;
>     ACCEPTUNLOCK(data->o2);
>     RunAccepted( acceptfd, data->HandlerRoutine ) ;
>     free(data);
> #ifndef VALGRIND
>     pthread_exit((void *)0);
> #endif /* VALGRIND */
>     return NULL;
> }
> 
284,294d309
<     /* embedded function */
<     void RunAccepted( int rafd ) {
<         if ( rafd>=0 ) {
<             HandlerRoutine( rafd ) ;
<             close( rafd ) ;
<         } else {
<             STAT_ADD1(NET_accept_errors);
<             LEVEL_CONNECT("accept() error %d [%s]\n", errno, strerror(errno));
<         }
<     }
< 
300,310d314
<         /* Doubly Embedded function */
<         void * AcceptThread( void * v2 ) {
<             struct connection_out *o2 = (struct connection_out *)v2;
<             int acceptfd = accept( o2->fd, NULL, NULL ) ;
<             ACCEPTUNLOCK(o2);
<             RunAccepted( acceptfd ) ;
< #ifndef VALGRIND
<             pthread_exit((void *)0);
< #endif /* VALGRIND */
<             return NULL;
<         }
315c319,324
<             if ( pthread_create( &thread2, attr_p, AcceptThread, out2 ) ) Exit(1) ;
---
>             /* Start a thread running AcceptThread(), all necessary parameters are passed
>                using a struct AcceptThread_data */
>             struct AcceptThread_data * data = malloc(sizeof(struct AcceptThread_data));
>             data->o2 = out2;
>             data->HandlerRoutine = HandlerRoutine;
>             if ( pthread_create( &thread2, attr_p, AcceptThread, data ) ) Exit(1) ;

Reply via email to