lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Pagefault while calling lwip_gethostbyname


From: Kieran Mansley
Subject: Re: [lwip-users] Pagefault while calling lwip_gethostbyname
Date: Fri, 16 Jul 2010 08:58:57 +0100

On Wed, 2010-07-07 at 20:27 -0400, Karthik Vadambacheri Manian wrote:
> Hi All,
> 
> I am trying to invoke lwip_gethostbyname(const char *name) but
> actually it results in a pagefault. On further investigation I found
> that lwip_gethostbyname(const char *name) inturn calls
> netconn_gethostbyname(const char *name, struct ip_addr *addr). Here a
> variable by name 'msg' of struct dns_api_msg is defined and
> initialized. Then the function do_gethostbyname(void *arg) is set as
> the tcpip callback function with the previously declared variable msg
> as the argument.

The msg variable is allocated on the stack of the calling thread.  The
tcpip_callback will result in a thread switch to the internal tcpip
thread to process the request.  This assumes that the memory used by the
msg variable is accessible by the tcpip thread.  Perhaps in your case
thread support in your port is structured such that this isn't
possible?  

The other way that this could go wrong is if the caller didn't wait
after calling tcpip_callback().  It uses a semaphore to wait for the
callback to return, but if this wasn't working properly the calling
function could carry on and exit making the msg variable on its stack
invalid.

Hope that helps you track down your problem.

Kieran




reply via email to

[Prev in Thread] Current Thread [Next in Thread]