comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: IDL/DLM segmentation fault on reset
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: IDL/DLM segmentation fault on reset [message #72312 is a reply to message #72311] Tue, 31 August 2010 07:54 Go to previous messageGo to previous message
Karl[1] is currently offline  Karl[1]
Messages: 79
Registered: October 2005
Member
On Aug 30, 6:34 pm, Haje Korth <hajeko...@gmail.com> wrote:
> Hi,
> Have an interesting problem for DLM programmers out there. I have a C
> code for Linux that sets an environment variable using putenv() within
> a DLM. The code executes as designed but when I issue
> a .full_session_reset I get a segmentation fault and IDL exits
> ungracefully. I run the same code (with slightly different calling
> convention) under Windows without problems. Does anyone know why? Do I
> need some sort of exit handler for the DLM (similar to IDL_Load for
> startup)?
>
> Haje

The putenv() function just puts a pointer to the string in the
environment. It does not make a copy of the string.

The full session reset unloads the DLM. Your string argument to
putenv() probably resides in a static var in the DLM. The environment
is just a list of pointers to strings. When the DLM got unloaded, the
environment is left with an invalid pointer to a string. I can't say
exactly what was going on when the segmentation fault occurred, but it
is easy to imagine that some system routine running during the session
reset was probably walking the environment strings and hit the bogus
pointer.

You might try using setenv() instead. The setenv() function allocates
heap memory for environment strings, and thus avoids the string memory
from getting unallocated by a unload of a module or an automatic
variable going out of scope.

It worked on Windows because Windows probably stores the environment
strings differently.

Karl
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Insert an image in Excel
Next Topic: ITT Announces Acquisition of CREASO

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 11:15:42 PDT 2025

Total time taken to generate the page: 0.96238 seconds