hi,
setting the degug flag in 
 ret_err = fusion_shm_pool_create( state->dfb->fworld, "KitvPool", 0x500000,0, 
&state->dfb->pool );
seems to help.....awkward

ben

----- original message --------

Betreff: [directfb-dev] libfusion race condition
Gesendet: Wed, 17 May 2006
Von: "Ben Willers" <[EMAIL PROTECTED]>

> hi,
> 
> i just wrote two little applications, using libfusion for IPC. 
> they seem to run into an SIGSEGV under certain conditions.
> 
> i first start up my master application, followed by the client. the client
> crashes every _first_ time it is started.
> if i start it a second time against the still running master process, it
> works just as it is supposed to.
> 
> first some code snipplets:
> 
> //MASTER//
> /*the master allocates some memory*/
>  ret_err = fusion_shm_pool_create( state->dfb->fworld, "KitvPool",
> 0x500000,0, &state->dfb->pool );
> 
> /* Create the Arena */
>   fusion_arena_enter (state->dfb->fworld,"kitv",initializeKitvArena,
> initializeKitvArena,state,&state->dfb->arena,&ret_err);
> <---->
>   /* Allocate some memory for the main process structure */
>   state->kitv_main=(kitv_main_process_t*)SHMALLOC(state->dfb->pool,
> sizeof(kitv_main_process_t));
>   fusion_arena_add_shared_field (arena, "kitv_main", (void
> *)state->kitv_main );
> <---->  
> (this is called via rpc from the client)
>    kitv_screen_process_t *new_screen_process;
>    
>    /* first allocate the new screen_process structure */
>    new_screen_process =(kitv_screen_process_t*)SHMALLOC(state->dfb->pool,
> sizeof(kitv_screen_process_t)); 
> 
>    /* then publish the field */
>    fusion_arena_add_shared_field (state->dfb->arena, field_name, (void
> *)new_screen_process );
>    // sleep (1);
> 
> 
> //CLIENT//
>   /* first join the kitv arena */
>   fusion_arena_enter(dfb->fworld, "kitv",fusionJoin,fusionJoin,NULL,
> &dfb->arena, &ret_err );
>   
>   /* now get the kitv_main structure */
>   fusion_arena_get_shared_field(dfb->arena, "kitv_main", (void
> **)&kitv_main);
> 
>   (rpc init : see master )
> 
>   /* grab the new kitv_screen_process field, it is named after our pid */
>   dr = fusion_arena_get_shared_field(dfb->arena, screen_name, (void
> **)&kitv_screen);
>   if ( dr != DFB_OK ) {
>     printf ("init: failed get shared field %sn",screen_name);
>     exit ( -1 ); 
>   }
>   printf ("field %xn",kitv_screen);
>   printf (" found %dn",kitv_screen->id);
> >>SIGSEGV<< occurs here
> 
> 
> the debug/trace log 1st execution :
>  process with pid 20901 is the client
> (-) [Main Thread      12.559] (20901) Fusion/Main:         -> done.
> (0x805f2b0)
> (-) [Main Thread      12.559] (20901) Fusion/Arena: entering arena 'kitv'
> (joining)
> (-) [Fusion Dispatch  12.559] (20900) Fusion/SHMPool:   
> fusion_shm_pool_allocate( 0x200040b0, 140, unclear, 0xb5deee98 )
> (-) [Fusion Dispatch  12.559] (20900) Fusion/SHMHeap:       
> _fusion_shmalloc( 0x28614000, 140 )
> (-) [Fusion Dispatch  12.559] (20900) Fusion/SHMHeap:           
> _fusion_shmalloc( 0x28614000, 4096 )
> (-) [Fusion Dispatch  12.559] (20900) Fusion/SHMHeap:               
> morecore( 0x28614000, 4096 )
> (-) [Fusion Dispatch  12.559] (20900) Fusion/SHMHeap:                   
> align( 0x28614000, 4096 )
> (-) [Fusion Dispatch  12.559] (20900) Fusion/SHMHeap:                       
> __shmalloc_brk( 0x28614000, 4096 )
> (-) [Fusion Dispatch  12.559] (20900) Fusion/SHMHeap:                       
>   -> remapped (28672 -> 32768)
> (-) [Fusion Dispatch  12.559] (20900) Fusion/SHMPool:   
> fusion_shm_pool_allocate( 0x2000406c, 116, clear, 0xb5deee98 )
> (-) [Fusion Dispatch  12.559] (20900) Fusion/SHMHeap:       
> _fusion_shmalloc( 0x28513000, 116 )
> (-) [Fusion Dispatch  12.560] (20900) Fusion/SHMPool:   
> fusion_shm_pool_allocate( 0x2000406c, 102, unclear, 0xb5deee98 )
> (-) [Fusion Dispatch  12.560] (20900) Fusion/SHMHeap:       
> _fusion_shmalloc( 0x28513000, 102 )
> (-) [Fusion Dispatch  12.560] (20900) Fusion/SHMPool:   
> fusion_shm_pool_allocate( 0x200040b0, 80, unclear, 0xb5deee28 )
> (-) [Fusion Dispatch  12.560] (20900) Fusion/SHMHeap:       
> _fusion_shmalloc( 0x28614000, 80 )
> (!) [20901:   12.560] --> Caught signal 11 (at 0x2861b004, invalid address)
> <--
> 
> the debug/trace log 2nd execution :
> now 20908 is the client
> (-) [Main Thread      16.084] (20908) Fusion/Arena: entering arena 'kitv'
> (joining)
> (-) [Fusion Dispatch  16.084] (20900) Fusion/SHMPool:   
> fusion_shm_pool_allocate( 0x200040b0, 140, unclear, 0xb5deee98 )
> (-) [Fusion Dispatch  16.084] (20900) Fusion/SHMHeap:       
> _fusion_shmalloc( 0x28614000, 140 )
> (-) [Fusion Dispatch  16.084] (20900) Fusion/SHMPool:   
> fusion_shm_pool_allocate( 0x2000406c, 116, clear, 0xb5deee98 )
> (-) [Fusion Dispatch  16.084] (20900) Fusion/SHMHeap:       
> _fusion_shmalloc( 0x28513000, 116 )
> (-) [Fusion Dispatch  16.084] (20900) Fusion/SHMPool:   
> fusion_shm_pool_allocate( 0x2000406c, 102, unclear, 0xb5deee98 )
> (-) [Fusion Dispatch  16.084] (20900) Fusion/SHMHeap:       
> _fusion_shmalloc( 0x28513000, 102 )
> (-) [Screen Update    16.084] (20899) SDL/Updates:             -> unlocking
> dfb surface...
> (-) [Screen Update    16.084] (20899) Core/Surface:             
> dfb_surface_unlock( 0x20016460, front )
> (-) [Screen Update    16.084] (20899) Core/Surface:                ->
> system/video count: 1/0 before
> (-) [Screen Update    16.084] (20899) Core/Surface:                ->
> system/video count: 0/0 after
> (-) [Screen Update    16.084] (20899) SDL/Updates:             -> unlocking
> sdl surface...
> (-) [Screen Update    16.084] (20899) SDL/Updates:             -> calling
> SDL_UpdateRect()...
> (-) [Fusion Dispatch  16.086] (20897) Fusion/SHMPool:   
> fusion_shm_pool_deallocate( 0x200000b0, 0x20115c80 )
> (-) [Fusion Dispatch  16.086] (20897) Fusion/SHMHeap:        _fusion_shfree(
> 0x20111000, 0x20115c80 )
> (-) [Screen Update    16.087] (20899) SDL/Updates:             -> unlocking
> sdl lock...
> (-) [Screen Update    16.087] (20899) SDL/Updates:             -> done.
> (*) Direct/Interface: Loaded 'JPEG' implementation of
> 'IDirectFBImageProvider'.
> (-) [Main Thread      16.087] (20908) Core/Layers:      
> dfb_layer_get_active_context (SDL Primary Layer)
> >>works fine now<<
> 
> if i enable the sleep (1); in the master code above everything works fine.
> 
> to me it looks like the shared memory is inconsistent while remapping. it
> might need some locking.
> for a start i tried locking the arenas_lock in the FusionSharedWorld from
> fusion_get_shared_field and fusion_shm_pool_allocate . it doesn't really
> help though. it's  working from time to time now, but propably just because
> it's slowing stuff down a lot.
> 
> i keep on trying, but my knowledge of the whole fusion stuff is  pretty
> limited.
> 
> apart from this bug(?, or is it just me being to stupid, allocating the pool
> wrong or whatever) the whole  directfb library is _very_ enjoyable and
> straightforward to use. thanks a lot!
> 
> ben
> 
> 
> 
> 
> _______________________________________________
> directfb-dev mailing list
> [email protected]
> http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev
> 

--- original message end ----


_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to