malloc_g + nic_parse_subopts

bridged with
Post Reply
Johan Björk

malloc_g + nic_parse_subopts

Post by Johan Björk » Sun Nov 30, 2003 6:04 pm

Hi everyone

I tried linking my network driver with malloc_g, and to my suprise the
first thing when I load my driver is that a error is generated in

My code basically looks like this:
#define BCM4400_OFFSET(a) offsetof(bcm4400_options_t,a)
static drvr_subopt_tbl_t bcm4400OptionsTable[] =

typedef struct {
nic_options_t nic;

//bcm4400 specific options
uint32_t flowcontrol;
} bcm4400_options_t;

typedef struct bleh {

bcm4400_options_t options;

int bcm4400_init (void *dll_hdl, dispatch_t *dpp, io_net_self_t *ion,
char *options)
struct itimerspec tvalue;
struct sigevent event;
uint16_t lan;
pthread_attr_t pattr;
struct sched_param param;
Nic_t *nic;
int ret;
drvr_subopt_tbl_chain_t link;

if(pci_attach(0) == -1 ) {
DbgPrint("Can't attach to the pci server! %d",errno);
return errno;

/* let's alloc a nic structure and put our PUM_DEVICE_BLOCK inside it */
nic = nic_create_dev(sizeof(UM_DEVICE_BLOCK));
handle->nic = nic; //so we can access the nic struct from the callbacks
from the platform independant code.

//setup a few defaults
handle->options.nic.promiscuous = -1;
handle->options.nic.nomulticast = -1; = NULL;
link.table = bcm4400OptionsTable;
link.table_size = sizeof(bcm4400OptionsTable) / sizeof(drvr_subopt_tbl_t);
if((ret =
nic_parse_subopts(&handle->options,"devn-bcm4400",options,&link)) != EOK) {
DbgPrint("Failure parsing commandline options");
goto err1;

gdb say this:
/src/lib/c/alloc/dlist.c:637 - fatal alloc error - free malloc object
that is not a

Program received signal SIGSEGV, Segmentation fault.
0xb82139e4 in _malloc_error () from /x86/usr/lib/
(gdb) bt
#0 0xb82139e4 in _malloc_error () from /x86/usr/lib/
#1 0xb8210f7e in _list_release () from /x86/usr/lib/
#2 0xb8211af8 in _free () from /x86/usr/lib/
#3 0xb82114d2 in _free_direct () from /x86/usr/lib/
#4 0xb821148d in __free () from /x86/usr/lib/
#5 0xb82114fb in free () from /x86/usr/lib/
#6 0xb8208da6 in nic_parse_subopts ()
#7 0xb8206fbe in bcm4400_init (dll_hdl=0x805c2c0, dpp=0x805b318,
options=0x8047ca1 "verbose=5")

Am I able to use the malloc_g lib on a shared library like this/Am I
using the helper function in a errornous way/is there acctually a
memoryproblem inside that function?

If I don't specify any arguments to my plugin, the problem isn't there.
(also, the plugin seemingly work fine even with arguments running
without malloc_g)

I'm running QNX 6.2.1B PE.

Thanks in Advance

/Johan Björk

Post Reply

Return to “”