wryun / es-shell

es: a shell with higher-order functions
http://wryun.github.io/es-shell/
Other
307 stars 25 forks source link

Segfaults with GCDEBUG enabled #18

Closed jpco closed 10 months ago

jpco commented 7 years ago

Enabling the GCDEBUG flag (equivalent to both GCALWAYS and GCPROTECT) causes two segfaults to occur, one in $&fsplit, and one in exception-handling code.

The $&fsplit segfault happens at split.c:99, because with GCALWAYS, the mkstr and mklist calls start a GC, which makes s point to invalid memory, which causes a segfault when GCPROTECT is enabled. I have a fix implemented for this (essentially, a re-entrant implementation of splitstring) which I'll create a PR with later.

The exception-handling segfault happens at prim-etc.c:254 when GCALWAYS is enabled (this case does not require GCPROTECT to be enabled to happen, though it's a fatal failure either way). I suspect one of the GCs that get triggered during the chained mklist and mkstrs around prim-ctl.c:70 are to blame, but I'm not confident enough with the Refs to know quite how to fix it.

jpco commented 7 years ago

The command echo ~ also seems to go poorly when GCALWAYS enabled -- if GCPROTECT is on, it results in a segfault; if not, echo ~ literally echoes ~ (expected behavior is printing whatever %home returns). Bug is somewhere around glob.c:278.

wryun commented 6 years ago

@jpco thanks for raising this. I'm not planning to look into it any time soon, but any PRs gratefully accepted :)