[GRASS-dev] [GRASS GIS] #1073: G_fatal_error segfault outside of GRASS session

#1073: G_fatal_error segfault outside of GRASS session
-----------------------+----------------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Keywords: | Platform: MacOSX
      Cpu: OSX/Intel |
-----------------------+----------------------------------------------------
When any module is run outside of a GRASS session, G_fatal_error itself
segfaults. This causes a loop for a while until the system gives up.

From the OSX crashlog:

{{{
OS Version: Mac OS X 10.6.3 (10D573)
Report Version: 6

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00007fff5f3fec50
Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 libgrass_gis.dylib 0x000000010006d364 vfprint_error +
20
1 libgrass_gis.dylib 0x000000010006db22 G_fatal_error +
170
2 libgrass_gis.dylib 0x000000010006d046 G_getenv + 37
3 libgrass_gis.dylib 0x000000010006d468 vfprint_error +
280
4 libgrass_gis.dylib 0x000000010006db22 G_fatal_error +
170
5 libgrass_gis.dylib 0x000000010006d046 G_getenv + 37
6 libgrass_gis.dylib 0x000000010006d468 vfprint_error +
280
7 libgrass_gis.dylib 0x000000010006db22 G_fatal_error +
170
...
}}}

This repeats for about 510 lines. I believe it should be printing a
message that I need to run the module within a GRASS session.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1073&gt;
GRASS GIS <http://grass.osgeo.org>

#1073: G_fatal_error segfault outside of GRASS session
------------------------+---------------------------------------------------
  Reporter: kyngchaos | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: normal | Milestone: 6.4.0
Component: default | Version: 6.4.0 RCs
Resolution: | Keywords:
  Platform: MacOSX | Cpu: OSX/Intel
------------------------+---------------------------------------------------
Comment (by glynn):

Replying to [ticket:1073 kyngchaos]:
> When any module is run outside of a GRASS session, G_fatal_error itself
segfaults. This causes a loop for a while until the system gives up.

In 7.0, r40465 was made to protect against infinite recursion. At that
time, it was determined that the issue couldn't arise with 6.x, but either
that was incorrect or something has changed.

AFAICT, the issue is due to log_error calling G_gisbase(); I have no idea
why it's doing this, as it uses the result as a truth value, but
G_gisbase() ends up calling G_fatal_error() if GISBASE is unset.

In any case, something similar to r40465 will work for 6.x.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1073#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1073: G_fatal_error segfault outside of GRASS session
-----------------------------+----------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.0
Component: LibGIS | Version: 6.4.0 RCs
Keywords: G_fatal_error() | Platform: MacOSX
      Cpu: OSX/Intel |
-----------------------------+----------------------------------------------
Changes (by hamish):

  * keywords: => G_fatal_error()
  * component: Default => LibGIS

Comment:

still happening?

I get a complaint about "error while loading shared libraries, cannot open
shared object file: No such file or directory" if I try to run a C module
outside of a GRASS session.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1073#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1073: G_fatal_error segfault outside of GRASS session
-----------------------------+----------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.0
Component: LibGIS | Version: 6.4.0 RCs
Keywords: G_fatal_error() | Platform: MacOSX
      Cpu: OSX/Intel |
-----------------------------+----------------------------------------------

Comment(by glynn):

Replying to [comment:2 hamish]:

> I get a complaint about "error while loading shared libraries, cannot
open shared object file: No such file or directory" if I try to run a C
module outside of a GRASS session.

That's to be expected; the loader needs LD_LIBRARY_PATH (DYLD_LIBRARY_PATH
on OSX, PATH on Windows) to be set in order to locate the GRASS libraries.

To check for this specific issue, either set PATH and LD_LIBRARY_PATH
(etc) manually, or start a GRASS session then manually unset GISBASE and
GISRC with:
{{{
export -n GISBASE GISRC
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1073#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#1073: G_fatal_error segfault outside of GRASS session
-----------------------------+----------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.4
Component: LibGIS | Version: 6.4.0 RCs
Keywords: G_fatal_error() | Platform: MacOSX
      Cpu: OSX/Intel |
-----------------------------+----------------------------------------------
Changes (by neteler):

  * milestone: 6.4.0 => 6.4.4

Comment:

Replying to [comment:1 glynn]:
> Replying to [ticket:1073 kyngchaos]:
> > When any module is run outside of a GRASS session, G_fatal_error
itself segfaults. This causes a loop for a while until the system gives
up.
>
> In 7.0, r40465 was made to protect against infinite recursion. At that
time, it was determined that the issue couldn't arise with 6.x, but either
that was incorrect or something has changed.

Backported to 6.5.svn in r52774. Still open for 6.4.svn.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1073#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#1073: G_fatal_error segfault outside of GRASS session
-----------------------------+----------------------------------------------
Reporter: kyngchaos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.4
Component: LibGIS | Version: 6.4.0 RCs
Keywords: G_fatal_error() | Platform: MacOSX
      Cpu: OSX/Intel |
-----------------------------+----------------------------------------------

Comment(by hamish):

Replying to [comment:4 neteler]:
> Replying to [comment:1 glynn]:
> > Replying to [ticket:1073 kyngchaos]:
> > > When any module is run outside of a GRASS session, G_fatal_error
itself
> > > segfaults. This causes a loop for a while until the system gives
up.
> >
> > In 7.0, r40465 was made to protect against infinite recursion. At that
time, it
> > was determined that the issue couldn't arise with 6.x, but either
that was
> > incorrect or something has changed.
>
> Backported to 6.5.svn in r52774. Still open for 6.4.svn.

to do now or later?

H

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1073#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#1073: G_fatal_error segfault outside of GRASS session
------------------------+---------------------------------------------------
  Reporter: kyngchaos | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 6.4.4
Component: LibGIS | Version: 6.4.0 RCs
Resolution: fixed | Keywords: G_fatal_error()
  Platform: MacOSX | Cpu: OSX/Intel
------------------------+---------------------------------------------------
Changes (by neteler):

  * status: new => closed
  * resolution: => fixed

Comment:

Backported to relbr64 in r60002

Tested with (as per comment:2)
{{{
export -n GISBASE GISRC ; g.version -r
}}}

No more segfault. Closing.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1073#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>