help-bash
[Top][All Lists]
Advanced

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

how to disable use of xmalloc in Bash


From: Tomás O'Hara
Subject: how to disable use of xmalloc in Bash
Date: Wed, 5 Jul 2023 00:28:17 -0500

Hi, is there a straightforward way to disable use of xmalloc in Bash?  I'm
tracking down segmentation faults in the Bash2Py utility that uses the Bash
code base:

https://www.swag.uwaterloo.ca/bash2py/index.html


The last few versions no longer work without crashing, however, Version 2.3
of Bash2Py works fine, as noted here [
https://unix.stackexchange.com/questions/627842/problem-when-converting-bash-to-python-using-bash2py].
Following this lead, I tracked down the issue to the use of xmalloc, which
were added in later versions. (Unfortunately, Bash2Py is no longer
supported as the professor who developed it retired.)

A workaround for this is to map the xmalloc calls into regular malloc:

# if !defined (_DISABLE_XMALLOC_H_)
#   define _DISABLE_XMALLOC_H_

#   include "stdc.h"
#   include "bashansi.h"

#   define xmalloc malloc
#   define xrealloc realloc
#   define xfree free

# endif /* _DISABLE_XMALLOC_H_ */


This works fine for the 15 Bash source files in Bash2py proper:

arrayfunc.c  burp.c  copy_cmd.c  eval.c  execute_cmd.c  fix_string.c
jobs.c  make_cmd.c   pcomplete.c  print_cmd.c  shell.c  subst.c
translate.c  translate_expr.c  variables.c  version.c  y.tab.c

The utility runs and is partly functional. However, I'm running into
compilation problems when trying to disable xmalloc for the entire Bash
build (e.g., including builtings and readline). For example, the make files
when trying to compile mkbuiltins.c due to the different ways malloc was
defined (e.g., incompatible pointer types).

I'm hoping the is some type of configuration switch that would disable
xmalloc, analogous to *--without-bash-malloc*. A complication is that there
are several different xmalloc implementations in the code base.

I can provide more details on the segmentation faults if desired. This
occurs for nearly all of the 500+ test files in the main test directory for
the xmalloc version of the latest Bash2Py source (3.6). In contrast,
Version 2.3 of only aborted on 3% of them.

Best,
Tom


reply via email to

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