[odb-users] ODB crashes: terminate called after throwing an instance of 'cutl::compiler::context::no_entry'

Alexis Mestag alexis.mestag at epitech.eu
Sat Apr 4 22:11:53 EDT 2015


Hello,

I'm currently trying to implement a bidirectionnal relationship using ODB. I
have 2 classes Alert and Profile, and I want a profile to have a list of
alerts. The two classes inherit from an Entity class which declares an id as
unsigned long and are as followed:

- Entities/Alert.hh:

# include		<memory>
# include		<set>
# include		<odb/core.hxx>
# include		"Entities/Entity.hh"
# include		"Entities/Information.hh"
# include		"Entities/Profile.hh"
# include		"Entities/User.hh"

class			Alert : public Entity
{
  friend class		odb::access;
    
public:
  typedef std::set<std::shared_ptr<User>>	Users;
    
private:
  Information			_information;
  Users				_users;
  std::shared_ptr<Profile>	_profile;

private:
  Alert() = default;

public:
  Alert(Information const &information);
  Alert(Alert const &rhs) = default;

  Alert				&operator=(Alert const &rhs) = default;

  ~Alert() = default;

public:
  bool				operator==(Alert const &rhs) const;
  bool				operator!=(Alert const &rhs) const;

public:
  Information const		&getInformation() const;
  void      			setInformation(Information const &information);

  Users const			&getUsers() const;
  void				setUsers(Users const &users);
  void				addUser(Users::value_type const &user);
  void				removeUser(Users::value_type const &rhs);

public:
  virtual void			serialize(Json::Value &json) const override;
};

# ifdef ODB_COMPILER
#  pragma db object(Alert)
#  pragma db member(Alert::_information)
#  pragma db member(Alert::_users)
#  pragma db member(Alert::_profile)
# endif

- Entities/Profile.hh

# include		<list>
# include		<memory>
# include		<string>
# include		<odb/core.hxx>

# include		"Entities/Entity.hh"

class			Alert;
class			TimeSlot;

class			Profile : public Entity
{
  friend classodb::access;

public:
  typedef std::list<std::weak_ptr<Alert>>	Alerts;
  typedef std::list<std::weak_ptr<TimeSlot>>	TimeSlots;

private:
  int			_polling;
  Alerts		_alerts;
  TimeSlots		_timeSlots;

 protected:
  Profile() = default;
  Profile(Profile const &rhs) = default;

  Profile&		operator=(Profile const &rhs) = default;

  Profile(int const polling);

 public:
  virtual ~Profile() = default;

 public:
  int			getPolling() const;
  void			setPolling(int const polling);

  Alerts const		&getAlerts() const;
  void			setAlerts(Alerts const &alerts);
  void			addAlert(Alerts::value_type const &alert);
  void			removeAlert(Alerts::value_type const &alert);

  TimeSlots const	&getTimeSlots() const;
  void			setTimeSlots(TimeSlots const &timeSlots);
  void			addTimeSlot(TimeSlots::value_type const &timeSlot);
  void			removeTimeSlot(TimeSlots::value_type const &timeSlot);

 public:
  virtual void		serialize(Json::Value &json) const override;
};

# include		"Entities/Alert.hh"
# include		"Entities/TimeSlot.hh"

# ifdefODB_COMPILER
#  pragma db object(Profile) polymorphic
#  pragma db member(Profile::_polling)
#  pragma db member(Profile::_alerts) inverse(_profile) value_not_null
#  pragma db member(Profile::_timeSlots) inverse(_profile) value_not_null
# endif

 The problem is, when I try to compile, ODB crashes:
$ make
odb -d mysql -q -s -e --std c++11 --default-pointer 'std::shared_ptr'
--cxx-suffix .cpp --generate-schema --generate-session -I Headers -o
Headers/Entities Headers/Entities/Alert.hh
terminate called after throwing an instance of
'cutl::compiler::context::no_entry'
  what():  N4cutl8compiler7context8no_entryE
  *** WARNING *** there are active plugins, do not report this as a bug
unless you can reproduce it without enabling any plugins.
Event                            | Plugins
PLUGIN_START_UNIT                | odb
PLUGIN_PRAGMAS                   | odb
PLUGIN_OVERRIDE_GATE             | odb
In file included from Headers/Entities/Alert.hh:20:0:
Headers/Entities/User.hh: In function ‘std::string
CryptoPP::StringNarrow(const wchar_t*, bool)’:
Headers/Entities/User.hh:27:49: internal compiler error: Aborted
   typedef ByteArray<CryptoPP::SHA1::DIGESTSIZE> hash_type;
                                                 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.archlinux.org/> for instructions.
Makefile:84: recipe for target 'Headers/Entities/Alert-odb.cpp' failed
make: *** [Headers/Entities/Alert-odb.cpp] Error 1
odb -d mysql -q -s -e --std c++11 --default-pointer 'std::shared_ptr'
--cxx-suffix .cpp --generate-schema --generate-session -I Headers -o
Headers/Entities Headers/Entities/Alert.hh
terminate called after throwing an instance of
'cutl::compiler::context::no_entry'
  what():  N4cutl8compiler7context8no_entryE
  *** WARNING *** there are active plugins, do not report this as a bug
unless you can reproduce it without enabling any plugins.
Event                            | Plugins
PLUGIN_START_UNIT                | odb
PLUGIN_PRAGMAS                   | odb
PLUGIN_OVERRIDE_GATE             | odb
In file included from Headers/Entities/Alert.hh:20:0:
Headers/Entities/User.hh: In function ‘std::string
CryptoPP::StringNarrow(const wchar_t*, bool)’:
Headers/Entities/User.hh:27:49: internal compiler error: Aborted
   typedef ByteArray<CryptoPP::SHA1::DIGESTSIZE> hash_type;
                                                 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.archlinux.org/> for instructions.
Makefile:84: recipe for target 'Headers/Entities/Alert-odb.cpp' failed
make: *** [Headers/Entities/Alert-odb.cpp] Error 1

I have no idea what causes this crash, I can't understand what the problem
is from the crash report.
Is there a problem on my part ? I post the User.hh file too since the error
message mentions it, but I am not sure it will help resolve the problem.

- Entities/User.hh:


# include		<array>
# include		<string>
# include		"Entities/Entity.hh"
# include		"Utils/ByteArray.hpp"

# include		<cryptopp/sha.h>
# include		<odb/core.hxx>

class			User : public Entity
{
  friend classodb::access;

public:
  typedef ByteArray<CryptoPP::SHA1::DIGESTSIZE>hash_type;

private:
  std::string		_name;
  std::string		_surname;
  std::string		_email;
  hash_type		_hash;
  hash_type		_salt;

private:
  User() = default;
  
public:
  User(User const &rhs) = delete;
  User(std::string const &name, std::string const &surname,
       std::string const &email);

  User&			operator=(User const &rhs) = delete;
  
  ~User() = default;

public:
  std::string const	&getName() const;
  void			setName(std::string const &name);

  std::string const	&getSurname() const;
  void			setSurname(std::string const &surname);

  std::string const	&getEmail() const;
  void			setEmail(std::string const &email);

  hash_type::type const	&getHash() const;
  void			setPassword(std::string const &password);

  hash_type::type const	&getSalt() const;

public:
  virtual void		serialize(Json::Value &json) const override;
};

# ifdefODB_COMPILER
#  pragma db value(User::hash_type)
#  pragma db member(User::hash_type::_array) transient
#  pragma db member(User::hash_type::_hex) get(toHexString) set(setHexString(?))

#  pragma db object(User)
#  pragma db member(User::_name)
#  pragma db member(User::_surname)
#  pragma db member(User::_email)
#  pragma db member(User::_hash)
#  pragma db member(User::_salt)
# endif

I am not sure I posted everything which is needed to solve this, so don't
hesitate to ask me more about my code.

thanks in advance,

Alexis MESTAG



More information about the odb-users mailing list