# cmake exception

**URL:** https://discourse.cmake.org/t/cmake-exception/2240
**Category:** Usage
**Created:** [November 25, 2020, 4:37pm UTC](https://discourse.cmake.org/t/cmake-exception/2240 "2020-11-25T16:37:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![kasha](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/ba9def/32.png) [@kasha](https://discourse.cmake.org/u/kasha)
#### Post date: [November 25, 2020, 4:37pm UTC](https://discourse.cmake.org/t/cmake-exception/2240/1 "2020-11-25T16:37:40Z")

</div>

```auto
 cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
-- Configuring done
terminate called after throwing an instance of 'std::out_of_range'
  what(): basic_string::replace: __pos (which is 18446744073709551615) > this->size() (which is 130)
Aborted (core dumped)

    cmake ..

```

works fine, until I enter `cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON` … after this command I have the same output for next `cmake ..` inputs

gdb backtrace:

```auto
(gdb) bt
#0 0x00007ffff694b428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff694d02a in __GI_abort () at abort.c:89
#2 0x00007ffff6f8584d in __gnu_cxx::__ verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff6f836b6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff6f83701 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff6f83919 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007ffff6fac3f7 in std::__throw_out_of_range_fmt(char const*, ...) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x00007ffff7016247 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::replace(unsigned long, unsigned long, char const*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#8 0x00000000006fd555 in cmMakefileTargetGenerator::WriteObjectBuildFile(std:: __cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__ cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cmSourceFile const&, std::vector<std:: __cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__ cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) ()
#9 0x00000000006ff57d in cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile const&) ()
#10 0x00000000006ffe2f in cmMakefileTargetGenerator::WriteTargetBuildRules() ()
#11 0x000000000070b271 in cmMakefileLibraryTargetGenerator::WriteRuleFiles() ()
#12 0x00000000006f3d26 in cmLocalUnixMakefileGenerator3::Generate() ()
#13 0x00000000006c19bb in cmGlobalGenerator::Generate() ()
#14 0x00000000006cf853 in cmGlobalUnixMakefileGenerator3::Generate() ()
#15 0x0000000000561297 in cmake::Generate() ()
#16 0x0000000000561763 in cmake::Run(std::vector<std:: __cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__ cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool) ()
#17 0x00000000004bdf94 in do_cmake(int, char const* const*) ()
#18 0x00000000004b98e6 in main ()

```

Tested on three Ubuntu distro. cmake versions: 3.10.0 and 3.5.1

What is the possible issue? Can`t find anything similar in Google at all

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [November 25, 2020, 5:38pm UTC](https://discourse.cmake.org/t/cmake-exception/2240/2 "2020-11-25T17:38:43Z")

</div>

Is the project you’re running this on available publicly?

Cc: @kyle.edwards @brad.king CMake crash here. Looks like an underflow (that position is `0xffffffffffffffff`) of some kind.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [November 25, 2020, 5:39pm UTC](https://discourse.cmake.org/t/cmake-exception/2240/3 "2020-11-25T17:39:03Z")

</div>

> [@kasha](#):
>
> cmake versions: 3.10.0 and 3.5.1

If it isn’t public, does the latest 3.19 release work?

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [November 25, 2020, 5:44pm UTC](https://discourse.cmake.org/t/cmake-exception/2240/4 "2020-11-25T17:44:52Z")

</div>

This was also reported as [CMake Issue 21506](https://gitlab.kitware.com/cmake/cmake/-/issues/21506). It is a duplicate of [CMake Issue 21471](https://gitlab.kitware.com/cmake/cmake/-/issues/21471), and is fixed in 3.19.1.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [November 25, 2020, 5:46pm UTC](https://discourse.cmake.org/t/cmake-exception/2240/5 "2020-11-25T17:46:25Z")

</div>

For reference, this happens on projects that override CMake’s builtin `CMAKE_C_COMPILE_OBJECT` rule with one that is missing the `<DEFINES>` or `<INCLUDES>` placeholders.
