This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with atexit and _dl_fini



On 22.05.19 21:34, Adhemerval Zanella wrote:

Do you have a easy way to provide the environment you are testing?

Now I can provide a way to reproduce the problem and debug it. While this may look a little daunting at first, it's mostly just copy/paste of commands and in the end you have a gdb session with a glibc that can be stepped through in the debugger.


atexit-bug.md

---

This is about the simplest way to reproduce the `atexit` problem in glibc.


## Create a docker with the development environment

Get the Dockerfile:

```
curl -L -O 'https://raw.githubusercontent.com/MulleFoundation/foundation-developer/release/Dockerfile'
```

As we want to debug with the newest **glibc** we need to use `ubuntu:disco`
instead of `ubuntu:bionic`, so change the first line of
the `Dockerfile` to `FROM ubuntu:disco`. Now you are ready to build the
container:


```
sudo docker build -t foundation -f Dockerfile "`mktemp -d`"
sudo docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -i -t --rm foundation
```


## Get some tools via apt

Inside the docker get some prerequisites for debugging and for **glibc**:

```
sudo apt-get -y install vim gdb gawk bison gettext texinfo
```

## Download the project

Inside the docker get the **MulleObjC** project. This will place you in a
virtual environment subshell.  With `exit` you can get out (you should).


```
mulle-sde https://github.com/mulle-objc/MulleObjC/archive/latest.tar.gz
exit
```


## Remove atexit fix

With the `atexit` fix, there are no problems, so we need to take it out:

```
cd MulleObjC/test
mulle-sde environment set MULLE_ATEXIT_URL 'https://github.com/mulle-core/mulle-atexit/archive/placebo.tar.gz'
```


## Build with a debug version of glibc

Build everything with a custom built version of **glibc**, so we can debug it.
While still being in `MulleObjC/test`:

```
mulle-sourcetree -N add --nodetype 'tar' --marks 'no-all-load,no-import' --userinfo 'aliases=c' --url '${GLIBC_2_29_URL:-https://ftp.gnu.org/gnu/glibc/glibc-2.29.tar.xz}' --branch '${GLIBC_2_29_BRANCH}' 'glibc'
mulle-sourcetree move glibc top
mulle-sde dependency craftinfo set glibc CC_DEBUG '-O1 -g'
mulle-sde dependency craftinfo set glibc SKIP_AUTOCONF YES
mulle-sde test craft
```

## Build first test and observe the error

While still being in `MulleObjC/test`:

```
mulle-sde -vvv test run --keep-exe 0_noleak/noleak.m
```

The error should appear.
Now you can look at the debugger to seem the wrong atexit order:

```
MULLE_TESTALLOCATOR=1 MULLE_OBJC_PEDANTIC_EXIT=YES gdb /MulleObjC/test/0_noleak/noleak.debug.exe
```

> Breakpoints to set:
>
> b atexit
> b mulle_testallocator_exit
> b mulle_objc_global_atexit


---


I tried these steps and it worked out successfully for me.


Good Luck

   Nat!



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]